xcb: rework connection error handling
This patch reworks 0b1ce5db9e
.
Just by looking at the source code it was unclear why is this
signal-and-slot connection necessary. It doesn't do anything on
normal exit - at the time we call dtor of this class,
QCoreApplication::instance() already is nullptr, which means that
no further event processing happens and we never get this signal.
Without digging into git history it may appear that the goal was
to process the remaining events on application exit, which would
be a questionable code by itself.
Change-Id: I202d11584901e3b52254d8e3c347aece17844b72
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
c89d0f9d53
commit
dd8a66daa4
@ -81,8 +81,6 @@ static bool dispatcherOwnerDestructing = false;
|
||||
QXcbEventQueue::QXcbEventQueue(QXcbConnection *connection)
|
||||
: m_connection(connection)
|
||||
{
|
||||
connect(this, &QXcbEventQueue::finished, m_connection, &QXcbConnection::processXcbEvents);
|
||||
|
||||
// When running test cases in auto tests, static variables are preserved
|
||||
// between test function runs, even if Q*Application object is destroyed.
|
||||
// Reset to default value to account for this.
|
||||
@ -199,14 +197,25 @@ void QXcbEventQueue::run()
|
||||
enqueueEvent(event);
|
||||
while (!m_closeConnectionDetected && (event = xcb_poll_for_queued_event(connection)))
|
||||
enqueueEvent(event);
|
||||
wakeUpDispatcher();
|
||||
}
|
||||
|
||||
QMutexLocker locker(&qAppExiting);
|
||||
if (!dispatcherOwnerDestructing) {
|
||||
// This thread can run before a dispatcher has been created,
|
||||
// so check if it is ready.
|
||||
if (QCoreApplication::eventDispatcher())
|
||||
QCoreApplication::eventDispatcher()->wakeUp();
|
||||
}
|
||||
if (!m_closeConnectionDetected) {
|
||||
// Connection was terminated not by us. Wake up dispatcher, which will
|
||||
// call processXcbEvents(), where we handle the connection errors via
|
||||
// xcb_connection_has_error().
|
||||
wakeUpDispatcher();
|
||||
}
|
||||
}
|
||||
|
||||
void QXcbEventQueue::wakeUpDispatcher()
|
||||
{
|
||||
QMutexLocker locker(&qAppExiting);
|
||||
if (!dispatcherOwnerDestructing) {
|
||||
// This thread can run before a dispatcher has been created,
|
||||
// so check if it is ready.
|
||||
if (QCoreApplication::eventDispatcher())
|
||||
QCoreApplication::eventDispatcher()->wakeUp();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,7 @@ public:
|
||||
bool isEmpty() const { return m_head == m_flushedTail && !m_head->event; }
|
||||
xcb_generic_event_t *takeFirst();
|
||||
void flushBufferedEvents();
|
||||
void wakeUpDispatcher();
|
||||
|
||||
// ### peek() and peekEventQueue() could be unified. Note that peekEventQueue()
|
||||
// is public API exposed via QX11Extras/QX11Info.
|
||||
|
Loading…
Reference in New Issue
Block a user