QWaylandDisplay: Correctly intercept all errors when dispatching.

A connection reset isn't the only form of error we may run into, so make sure we
check for other exceptional circumstances through wl_display_get_error.

This fixes my case of e.g. wl_drm throwing an error but QtWayland never
quitting the client.

Change-Id: I8c76dd7913640e58d03bd2fe52eb054a4daa0235
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
This commit is contained in:
Robin Burchell 2014-08-19 18:24:56 +02:00
parent 76f5ad1784
commit c6766fe4f4
2 changed files with 25 additions and 6 deletions

View File

@ -166,18 +166,31 @@ QWaylandDisplay::~QWaylandDisplay(void)
void QWaylandDisplay::flushRequests()
{
if (wl_display_dispatch_queue_pending(mDisplay, mEventQueue) == -1 && (errno == EPIPE || errno == ECONNRESET)) {
qWarning("The Wayland connection broke. Did the Wayland compositor die?");
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);
}
wl_display_flush(mDisplay);
}
void QWaylandDisplay::blockingReadEvents()
{
if (wl_display_dispatch_queue(mDisplay, mEventQueue) == -1 && (errno == EPIPE || errno == ECONNRESET)) {
qWarning("The Wayland connection broke. Did the Wayland compositor die?");
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);
}
}

View File

@ -73,8 +73,14 @@ void QWaylandEventThread::displayConnect()
void QWaylandEventThread::readWaylandEvents()
{
if (wl_display_dispatch(m_display) == -1 && (errno == EPIPE || errno == ECONNRESET)) {
qWarning("The Wayland connection broke. Did the Wayland compositor die?");
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);
}
emit newEventsRead();