diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 7435e124dc..1fcee9cd89 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -767,7 +767,10 @@ xcb_timestamp_t QXcbConnection::getTimestamp() xcb_generic_event_t *event = nullptr; - while (!event) { + // When disconnection is caused by X server, event will never be able to hold + // a valid pointer. isConnected(), which calls xcb_connection_has_error(), + // can handle this type of disconnection and properly quits the loop. + while (isConnected() && !event) { connection()->sync(); event = eventQueue()->peek([window, dummyAtom](xcb_generic_event_t *event, int type) { if (type != XCB_PROPERTY_NOTIFY) @@ -777,6 +780,14 @@ xcb_timestamp_t QXcbConnection::getTimestamp() }); } + if (!event) { + // https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#glossary + // > One timestamp value (named CurrentTime) is never generated by the + // > server. This value is reserved for use in requests to represent the + // > current server time. + return XCB_CURRENT_TIME; + } + xcb_property_notify_event_t *pn = reinterpret_cast<xcb_property_notify_event_t *>(event); xcb_timestamp_t timestamp = pn->time; free(event); |