summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2012-01-28 22:35:15 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-31 04:56:04 +0100
commit9464458098da637aa642917c782fa56bc9682802 (patch)
tree5d67a252d4a59afaaeb2ff7a59448006c0148f94 /src/plugins/platforms/xcb
parent98d34beb03018f9a0dcc371f9acabc40d9fdacce (diff)
xcb: Check for SHM extension before using it
If we call any xcb_shm_*() function, libxcb will have to figure out SHM's major number. However, if that fails because the SHM extension is not available, xcb will disconnect from the server. Obviously, that's not what we want and must be avoided. Change-Id: I8eba5ff9e84e0e2017a5c0d88fda4efd0459bd1e Signed-off-by: Uli Schlachter <psychon@znc.in> Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/plugins/platforms/xcb')
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
index 76304be541..b7369525a5 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -115,8 +115,12 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI
m_shm_info.shmaddr = m_xcb_image->data = (quint8 *)shmat (m_shm_info.shmid, 0, 0);
m_shm_info.shmseg = xcb_generate_id(xcb_connection());
- xcb_generic_error_t *error = xcb_request_check(xcb_connection(), xcb_shm_attach_checked(xcb_connection(), m_shm_info.shmseg, m_shm_info.shmid, false));
- if (error) {
+ 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;
+ 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));
+ if (!shm_present || error) {
free(error);
shmdt(m_shm_info.shmaddr);