summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Gräßlin <mgraesslin@kde.org>2015-02-16 15:50:11 +0100
committerMartin Gräßlin <mgraesslin@kde.org>2015-02-17 09:55:10 +0000
commit1e32e71403a6a9cb117343464fbc34564598e831 (patch)
tree7b9a720aa14557e3b3138439f2edddb63149858d
parent8458e06b25c07ebc8cf6b210fc1ea4cc9aeb42eb (diff)
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>
-rw-r--r--src/client/qwaylanddisplay.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
index 9dedabda3..11904ae07 100644
--- a/src/client/qwaylanddisplay.cpp
+++ b/src/client/qwaylanddisplay.cpp
@@ -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);