Run eventDispatcher in QWaylandDisplay::forceRoundTrip
If the application uses QCoreApplication::setEventDispatcher before the QGuiApplication is created the blocking roundtrip might block the application indefinitely. This can happen if the application starts a Wayland server in the same process before the QGuiApplication is created. And the QtWayland plugin connects to this server. In this case a roundtrip blocks as the Wayland server cannot process the events the QWaylandDisplay is waiting for. By running the event dispatcher manually and using the pending variant for dispatching the Wayland event queue, the application can be kept alive. Change-Id: I9c36fccbae8921e1ae9a0a8b7f460520b1b65d5c Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
This commit is contained in:
parent
520cb3e95e
commit
4ad52325f7
@ -338,8 +338,15 @@ void QWaylandDisplay::forceRoundTrip()
|
||||
wl_proxy_set_queue((struct wl_proxy *)callback, mEventQueue);
|
||||
wl_callback_add_listener(callback, &sync_listener, &done);
|
||||
flushRequests();
|
||||
while (!done && ret >= 0)
|
||||
ret = wl_display_dispatch_queue(mDisplay, mEventQueue);
|
||||
if (QThread::currentThread()->eventDispatcher()) {
|
||||
while (!done && ret >= 0) {
|
||||
QThread::currentThread()->eventDispatcher()->processEvents(QEventLoop::WaitForMoreEvents);
|
||||
ret = wl_display_dispatch_queue_pending(mDisplay, mEventQueue);
|
||||
}
|
||||
} else {
|
||||
while (!done && ret >= 0)
|
||||
ret = wl_display_dispatch_queue(mDisplay, mEventQueue);
|
||||
}
|
||||
|
||||
if (ret == -1 && !done)
|
||||
wl_callback_destroy(callback);
|
||||
|
Loading…
x
Reference in New Issue
Block a user