QWaylandDisplay: Centralize error handling in one place.
Change-Id: Ifba23e349a4006cea501480a7230408f0fafd1b7 Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
This commit is contained in:
parent
c6766fe4f4
commit
bb360fce60
@ -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
|
||||
|
@ -71,18 +71,25 @@ void QWaylandEventThread::displayConnect()
|
||||
QMetaObject::invokeMethod(this, "waylandDisplayConnect", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
// ### be careful what you do, this function may also be called from other
|
||||
// threads to clean up & exit.
|
||||
void QWaylandEventThread::checkErrorAndExit()
|
||||
{
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
if (wl_display_dispatch(m_display) < 0)
|
||||
checkErrorAndExit();
|
||||
|
||||
emit newEventsRead();
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,8 @@ public:
|
||||
|
||||
wl_display *display() const;
|
||||
|
||||
void checkErrorAndExit();
|
||||
|
||||
private slots:
|
||||
void readWaylandEvents();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user