From f7e6a478b7d4ccb04bc41a2b93162224e73162be Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 22 Nov 2017 16:10:39 +0100 Subject: [PATCH] Fix tst_client::windowScreen and tst_client::screens sometimes freezing Sometimes the callback in forceRoundTrip would be handled in response to the QEventDispatcher::aboutToBlockSignal signal emitted at the start of processEvents, and would wait there for more events that may never come. Task-number: QTBUG-64696 Change-Id: I4e38a4dd4158afc606e779ff615b5eef98b955b0 Reviewed-by: Giulio Camuffo --- src/plugins/platforms/wayland/qwaylanddisplay.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index b2372f08898..178b26199d9 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -343,6 +343,15 @@ sync_callback(void *data, struct wl_callback *callback, uint32_t serial) bool *done = static_cast(data); *done = true; + + // If the wl_callback done event is received after the condition check in the while loop in + // forceRoundTrip(), but before the call to processEvents, the call to processEvents may block + // forever if no more events are posted (eventhough the callback is handled in response to the + // aboutToBlock signal). Hence, we wake up the event dispatcher so forceRoundTrip may return. + // (QTBUG-64696) + if (auto *dispatcher = QThread::currentThread()->eventDispatcher()) + dispatcher->wakeUp(); + wl_callback_destroy(callback); }