summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbconnection.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-08-11 12:01:12 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-08-16 15:52:02 +0000
commitcdc79f5ebc0ec1898e3845acb9c880b5e69e593b (patch)
tree18f2b3a12d77d33b6cc859b502358976c169264d /src/plugins/platforms/xcb/qxcbconnection.cpp
parentbaf1158c48c3342f4e90d83c3b93236535aac285 (diff)
XCB: Don't core-dump if we can't connect to the X displayName
Exit with error, but don't crash. Change-Id: Ie05c6480d8a44fda817ffffd14d9dfd8c951beef Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection.cpp')
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index e167ba1231..d36a14b920 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -571,9 +571,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();
@@ -668,7 +669,7 @@ QXcbConnection::~QXcbConnection()
finalizeXInput2();
#endif
- if (m_reader->isRunning()) {
+ if (m_reader && m_reader->isRunning()) {
sendConnectionEvent(QXcbAtom::_QT_CLOSE_CONNECTION);
m_reader->wait();
}
@@ -685,15 +686,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()) {