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()
|
void QWaylandDisplay::flushRequests()
|
||||||
{
|
{
|
||||||
if (wl_display_dispatch_queue_pending(mDisplay, mEventQueue) < 0) {
|
if (wl_display_dispatch_queue_pending(mDisplay, mEventQueue) < 0)
|
||||||
int ecode = wl_display_get_error(mDisplay);
|
mEventThreadObject->checkErrorAndExit();
|
||||||
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);
|
wl_display_flush(mDisplay);
|
||||||
}
|
}
|
||||||
@ -183,16 +175,8 @@ void QWaylandDisplay::flushRequests()
|
|||||||
|
|
||||||
void QWaylandDisplay::blockingReadEvents()
|
void QWaylandDisplay::blockingReadEvents()
|
||||||
{
|
{
|
||||||
if (wl_display_dispatch_queue(mDisplay, mEventQueue) < 0) {
|
if (wl_display_dispatch_queue(mDisplay, mEventQueue) < 0)
|
||||||
int ecode = wl_display_get_error(mDisplay);
|
mEventThreadObject->checkErrorAndExit();
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
|
QWaylandScreen *QWaylandDisplay::screenForOutput(struct wl_output *output) const
|
||||||
|
@ -71,9 +71,10 @@ void QWaylandEventThread::displayConnect()
|
|||||||
QMetaObject::invokeMethod(this, "waylandDisplayConnect", Qt::QueuedConnection);
|
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);
|
int ecode = wl_display_get_error(m_display);
|
||||||
if ((ecode == EPIPE || ecode == ECONNRESET)) {
|
if ((ecode == EPIPE || ecode == ECONNRESET)) {
|
||||||
// special case this to provide a nicer error
|
// special case this to provide a nicer error
|
||||||
@ -83,6 +84,12 @@ void QWaylandEventThread::readWaylandEvents()
|
|||||||
}
|
}
|
||||||
::exit(1);
|
::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QWaylandEventThread::readWaylandEvents()
|
||||||
|
{
|
||||||
|
if (wl_display_dispatch(m_display) < 0)
|
||||||
|
checkErrorAndExit();
|
||||||
|
|
||||||
emit newEventsRead();
|
emit newEventsRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +63,8 @@ public:
|
|||||||
|
|
||||||
wl_display *display() const;
|
wl_display *display() const;
|
||||||
|
|
||||||
|
void checkErrorAndExit();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void readWaylandEvents();
|
void readWaylandEvents();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user