diff options
author | Paul Olav Tvete <paul.tvete@nokia.com> | 2011-04-11 12:48:47 (GMT) |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@nokia.com> | 2011-04-11 12:55:17 (GMT) |
commit | 0108e888480e47e65d82d94e10a7c7c910e42d79 (patch) | |
tree | 7e467eb569aa9c2da2c61879645c82e66e2c7d0e /src/plugins/platforms/wayland/qwaylanddisplay.cpp | |
parent | fb297b316b1acfda133ce6d5b46c89eaf8475199 (diff) | |
download | Qt-0108e888480e47e65d82d94e10a7c7c910e42d79.zip Qt-0108e888480e47e65d82d94e10a7c7c910e42d79.tar.gz Qt-0108e888480e47e65d82d94e10a7c7c910e42d79.tar.bz2 |
Make readEvents() non-blocking
Another event handler could empty the Wayland socket after the
socket notifier has triggered, but before the signal is delivered.
Since wl_display_iterate is blocking, we have to test whether there
is data available to avoid freezing the whole application.
Reviewed-by: Samuel
Diffstat (limited to 'src/plugins/platforms/wayland/qwaylanddisplay.cpp')
-rw-r--r-- | src/plugins/platforms/wayland/qwaylanddisplay.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp index a6fdd46..eb9e791 100644 --- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp +++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp @@ -176,6 +176,30 @@ void QWaylandDisplay::flushRequests() void QWaylandDisplay::readEvents() { +// verify that there is still data on the socket + fd_set fds; + FD_ZERO(&fds); + FD_SET(mFd, &fds); + fd_set nds; + FD_ZERO(&nds); + fd_set rs = fds; + fd_set ws = nds; + fd_set es = nds; + timeval timeout; + timeout.tv_sec = 0; + timeout.tv_usec = 0; + int ret = ::select(mFd+1, &rs, &ws, &es, &timeout ); + + if (ret <= 0) { + //qDebug("QWaylandDisplay::readEvents() No data... blocking avoided"); + return; + } + + wl_display_iterate(mDisplay, WL_DISPLAY_READABLE); +} + +void QWaylandDisplay::blockingReadEvents() +{ wl_display_iterate(mDisplay, WL_DISPLAY_READABLE); } @@ -208,7 +232,7 @@ void QWaylandDisplay::waitForScreens() { flushRequests(); while (mScreens.isEmpty()) - readEvents(); + blockingReadEvents(); } void QWaylandDisplay::displayHandleGlobal(struct wl_display *display, |