diff options
author | Liang Qi <liang.qi@qt.io> | 2017-08-31 13:10:18 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-08-31 14:31:31 +0200 |
commit | 112a4af10741409b3d8503cb77852a777b607ce0 (patch) | |
tree | fa99f0f37fc1505522fe9368e95484c7732ccda8 /src/plugins/platforms/xcb | |
parent | 29ef0d2bccd1874e20de94485ee05777c3a95c5d (diff) | |
parent | e938150412d22e61926fe16791158805b71268bb (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
examples/examples.pro
qmake/library/qmakebuiltins.cpp
src/corelib/global/qglobal.cpp
Re-apply b525ec2 to qrandom.cpp(code movement in 030782e)
src/corelib/global/qnamespace.qdoc
src/corelib/global/qrandom.cpp
src/gui/kernel/qwindow.cpp
Re-apply a3d59c7 to QWindowPrivate::setVisible() (code movement in d7a9e08)
src/network/ssl/qsslkey_openssl.cpp
src/plugins/platforms/android/androidjniinput.cpp
src/plugins/platforms/xcb/qxcbconnection.cpp
src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
src/widgets/widgets/qmenu.cpp
tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
Change-Id: If7ab427804408877a93cbe02079fca58e568bfd3
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.cpp | 20 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbintegration.cpp | 17 |
3 files changed, 30 insertions, 8 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 23bb5c6410..536c709dbe 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -556,9 +556,10 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra m_connection = xcb_connect(m_displayName.constData(), &m_primaryScreenNumber); #endif // QT_CONFIG(xcb_xlib) - if (Q_UNLIKELY(!m_connection || xcb_connection_has_error(m_connection))) - qFatal("QXcbConnection: Could not connect to display %s", m_displayName.constData()); - + if (Q_UNLIKELY(!m_connection || xcb_connection_has_error(m_connection))) { + qCWarning(lcQpaScreen, "QXcbConnection: Could not connect to display %s", m_displayName.constData()); + return; + } m_reader = new QXcbEventReader(this); m_reader->start(); @@ -648,7 +649,7 @@ QXcbConnection::~QXcbConnection() #ifndef QT_NO_DRAGANDDROP delete m_drag; #endif - if (m_reader->isRunning()) { + if (m_reader && m_reader->isRunning()) { sendConnectionEvent(QXcbAtom::_QT_CLOSE_CONNECTION); m_reader->wait(); } @@ -665,15 +666,22 @@ QXcbConnection::~QXcbConnection() delete m_glIntegration; + if (isConnected()) { #if QT_CONFIG(xcb_xlib) - XCloseDisplay(static_cast<Display *>(m_xlib_display)); + XCloseDisplay(static_cast<Display *>(m_xlib_display)); #else - xcb_disconnect(xcb_connection()); + xcb_disconnect(xcb_connection()); #endif + } delete m_keyboard; } +bool QXcbConnection::isConnected() const +{ + return m_connection && !xcb_connection_has_error(m_connection); +} + QXcbScreen *QXcbConnection::primaryScreen() const { if (!m_screens.isEmpty()) { diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index a37ce5f5a6..999dc0630c 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -391,6 +391,7 @@ public: ~QXcbConnection(); QXcbConnection *connection() const { return const_cast<QXcbConnection *>(this); } + bool isConnected() const; const QList<QXcbVirtualDesktop *> &virtualDesktops() const { return m_virtualDesktops; } const QList<QXcbScreen *> &screens() const { return m_screens; } diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index c8efe2fce8..72d31060db 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -188,12 +188,25 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char const int numParameters = parameters.size(); m_connections.reserve(1 + numParameters / 2); - m_connections << new QXcbConnection(m_nativeInterface.data(), m_canGrab, m_defaultVisualId, displayName); + auto conn = new QXcbConnection(m_nativeInterface.data(), m_canGrab, m_defaultVisualId, displayName); + if (conn->isConnected()) + m_connections << conn; + else + delete conn; for (int i = 0; i < numParameters - 1; i += 2) { qCDebug(lcQpaScreen) << "connecting to additional display: " << parameters.at(i) << parameters.at(i+1); QString display = parameters.at(i) + QLatin1Char(':') + parameters.at(i+1); - m_connections << new QXcbConnection(m_nativeInterface.data(), m_canGrab, m_defaultVisualId, display.toLatin1().constData()); + conn = new QXcbConnection(m_nativeInterface.data(), m_canGrab, m_defaultVisualId, display.toLatin1().constData()); + if (conn->isConnected()) + m_connections << conn; + else + delete conn; + } + + if (m_connections.isEmpty()) { + qCritical("Could not connect to any X display."); + exit(1); } m_fontDatabase.reset(new QGenericUnixFontDatabase()); |