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 <giulio.camuffo@kdab.com>
This commit is contained in:
Johan Klokkhammer Helsing 2017-11-22 16:10:39 +01:00 committed by Johan Helsing
parent a6257efe0c
commit f7e6a478b7

View File

@ -343,6 +343,15 @@ sync_callback(void *data, struct wl_callback *callback, uint32_t serial)
bool *done = static_cast<bool *>(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);
}