diff --git a/src/backends/x11/windowed/x11_windowed_backend.cpp b/src/backends/x11/windowed/x11_windowed_backend.cpp index 4d717d0889..0ebf245577 100644 --- a/src/backends/x11/windowed/x11_windowed_backend.cpp +++ b/src/backends/x11/windowed/x11_windowed_backend.cpp @@ -172,7 +172,8 @@ X11WindowedBackend::~X11WindowedBackend() bool X11WindowedBackend::initialize() { m_connection = xcb_connect(m_options.display.toLatin1(), &m_screenNumber); - if (!m_connection) { + if (xcb_connection_has_error(m_connection)) { + xcb_disconnect(m_connection); return false; } diff --git a/tests/normalhintsbasesizetest.cpp b/tests/normalhintsbasesizetest.cpp index 373cc65375..593d49d0c6 100644 --- a/tests/normalhintsbasesizetest.cpp +++ b/tests/normalhintsbasesizetest.cpp @@ -34,6 +34,11 @@ int main(int, char **) int screenNumber; xcb_connection_t *c = xcb_connect(nullptr, &screenNumber); + if (xcb_connection_has_error(c)) { + xcb_disconnect(c); + return 1; + } + auto getScreen = [=]() { const xcb_setup_t *setup = xcb_get_setup(c); auto it = xcb_setup_roots_iterator(setup); diff --git a/tests/pointerconstraintstest.cpp b/tests/pointerconstraintstest.cpp index 1c9c7d08c5..835330b9d4 100644 --- a/tests/pointerconstraintstest.cpp +++ b/tests/pointerconstraintstest.cpp @@ -240,8 +240,10 @@ void XBackend::init(QQuickView *view) { Backend::init(view); m_xcbConn = xcb_connect(nullptr, nullptr); - if (!m_xcbConn) { - qDebug() << "Could not open XCB connection."; + + if (xcb_connection_has_error(m_xcbConn)) { + xcb_disconnect(m_xcbConn); + qFatal() << "Could not open XCB connection."; } }