diff options
author | Robin Burchell <robin.burchell@viroteck.net> | 2014-08-19 18:40:19 +0200 |
---|---|---|
committer | Robin Burchell <robin.burchell@viroteck.net> | 2014-08-19 18:46:11 +0200 |
commit | 564dd7ca4f1590da5559422e4ea98a2cef1992e6 (patch) | |
tree | 3ee3c68f4e4a2c5b866a65c21c8651c967d2ab98 /src/client | |
parent | cee3e127f4c9d57a00c55d57957a99c7061aa863 (diff) |
QWaylandDisplay: Centralize error handling in one place.
Change-Id: Ifba23e349a4006cea501480a7230408f0fafd1b7
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/qwaylanddisplay.cpp | 24 | ||||
-rw-r--r-- | src/client/qwaylandeventthread.cpp | 27 | ||||
-rw-r--r-- | src/client/qwaylandeventthread_p.h | 2 |
3 files changed, 23 insertions, 30 deletions
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index 74efbfda4..94bfa88bc 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -166,16 +166,8 @@ QWaylandDisplay::~QWaylandDisplay(void) void QWaylandDisplay::flushRequests() { - if (wl_display_dispatch_queue_pending(mDisplay, mEventQueue) < 0) { - int ecode = wl_display_get_error(mDisplay); - if ((ecode == EPIPE || ecode == ECONNRESET)) { - // special case this to provide a nicer error - qWarning("The Wayland connection broke. Did the Wayland compositor die?"); - } else { - qErrnoWarning(ecode, "The Wayland connection experienced a fatal error"); - } - ::exit(1); - } + if (wl_display_dispatch_queue_pending(mDisplay, mEventQueue) < 0) + mEventThreadObject->checkErrorAndExit(); wl_display_flush(mDisplay); } @@ -183,16 +175,8 @@ void QWaylandDisplay::flushRequests() void QWaylandDisplay::blockingReadEvents() { - if (wl_display_dispatch_queue(mDisplay, mEventQueue) < 0) { - int ecode = wl_display_get_error(mDisplay); - if ((ecode == EPIPE || ecode == ECONNRESET)) { - // special case this to provide a nicer error - qWarning("The Wayland connection broke. Did the Wayland compositor die?"); - } else { - qErrnoWarning(ecode, "The Wayland connection experienced a fatal error"); - } - ::exit(1); - } + if (wl_display_dispatch_queue(mDisplay, mEventQueue) < 0) + mEventThreadObject->checkErrorAndExit(); } QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const diff --git a/src/client/qwaylandeventthread.cpp b/src/client/qwaylandeventthread.cpp index 979aa6e0e..b7266765e 100644 --- a/src/client/qwaylandeventthread.cpp +++ b/src/client/qwaylandeventthread.cpp @@ -71,18 +71,25 @@ void QWaylandEventThread::displayConnect() QMetaObject::invokeMethod(this, "waylandDisplayConnect", Qt::QueuedConnection); } -void QWaylandEventThread::readWaylandEvents() +// ### be careful what you do, this function may also be called from other +// threads to clean up & exit. +void QWaylandEventThread::checkErrorAndExit() { - if (wl_display_dispatch(m_display) < 0) { - int ecode = wl_display_get_error(m_display); - if ((ecode == EPIPE || ecode == ECONNRESET)) { - // special case this to provide a nicer error - qWarning("The Wayland connection broke. Did the Wayland compositor die?"); - } else { - qErrnoWarning(ecode, "The Wayland connection experienced a fatal error"); - } - ::exit(1); + int ecode = wl_display_get_error(m_display); + if ((ecode == EPIPE || ecode == ECONNRESET)) { + // special case this to provide a nicer error + qWarning("The Wayland connection broke. Did the Wayland compositor die?"); + } else { + qErrnoWarning(ecode, "The Wayland connection experienced a fatal error"); } + ::exit(1); +} + +void QWaylandEventThread::readWaylandEvents() +{ + if (wl_display_dispatch(m_display) < 0) + checkErrorAndExit(); + emit newEventsRead(); } diff --git a/src/client/qwaylandeventthread_p.h b/src/client/qwaylandeventthread_p.h index 0d2758c4c..d51d627b9 100644 --- a/src/client/qwaylandeventthread_p.h +++ b/src/client/qwaylandeventthread_p.h @@ -63,6 +63,8 @@ public: wl_display *display() const; + void checkErrorAndExit(); + private slots: void readWaylandEvents(); |