1
0
forked from pool/libqt5-qtbase
libqt5-qtbase/libqt5-do-not-use-shm-if-display-name-doesnt-look-local.patch

40 lines
2.0 KiB
Diff

Do not use SHM if display name doesn't look local.
Verifying availability of SHM only by using response of SHM Attach is not
reliable. There is always small chance that when we are a remote client of X
server, we'll get shmid that is already in use by some local X client. In that
case X server can not recognize that it is not accessing our shared memory but
the one of the other client and will report success.
This adds check for display name equivalent to one that was in Qt4. Determining
whether the connection is local/remote from display name is not 100% reliable,
but worked fine for years in Qt4.
Signed-off-by: Michal Srb <msrb@suse.com>
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
index dc677cd..4cd249e 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -118,7 +118,8 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *s
m_shm_info.shmseg = xcb_generate_id(xcb_connection());
const xcb_query_extension_reply_t *shm_reply = xcb_get_extension_data(xcb_connection(), &xcb_shm_id);
- bool shm_present = shm_reply != NULL && shm_reply->present;
+ bool is_local = (!displayName() || displayName()[0] == ':');
+ bool shm_present = is_local && shm_reply != NULL && shm_reply->present;
xcb_generic_error_t *error = NULL;
if (shm_present)
error = xcb_request_check(xcb_connection(), xcb_shm_attach_checked(xcb_connection(), m_shm_info.shmseg, m_shm_info.shmid, false));
diff --git a/src/plugins/platforms/xcb/qxcbobject.h b/src/plugins/platforms/xcb/qxcbobject.h
index 354984c..2ecb5e7 100644
--- a/src/plugins/platforms/xcb/qxcbobject.h
+++ b/src/plugins/platforms/xcb/qxcbobject.h
@@ -48,6 +48,7 @@ public:
xcb_atom_t atom(QXcbAtom::Atom atom) const { return m_connection->atom(atom); }
xcb_connection_t *xcb_connection() const { return m_connection->xcb_connection(); }
+ const char *displayName() const { return m_connection->displayName(); }
private:
QXcbConnection *m_connection;