summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@nokia.com>2011-04-11 12:48:47 (GMT)
committerPaul Olav Tvete <paul.tvete@nokia.com>2011-04-11 12:55:17 (GMT)
commit0108e888480e47e65d82d94e10a7c7c910e42d79 (patch)
tree7e467eb569aa9c2da2c61879645c82e66e2c7d0e /src/plugins/platforms
parentfb297b316b1acfda133ce6d5b46c89eaf8475199 (diff)
downloadQt-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')
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.cpp26
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.h1
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.cpp2
3 files changed, 27 insertions, 2 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,
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.h b/src/plugins/platforms/wayland/qwaylanddisplay.h
index e02767d..3ddbfb2 100644
--- a/src/plugins/platforms/wayland/qwaylanddisplay.h
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.h
@@ -86,6 +86,7 @@ public:
public slots:
void createNewScreen(struct wl_output *output, QRect geometry);
void readEvents();
+ void blockingReadEvents();
void flushRequests();
private:
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp
index d58b39d..7e94fb9 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow.cpp
+++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp
@@ -154,5 +154,5 @@ void QWaylandWindow::waitForFrameSync()
{
mDisplay->flushRequests();
while (mWaitingForFrameSync)
- mDisplay->readEvents();
+ mDisplay->blockingReadEvents();
}