summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2014-08-21 15:33:09 +0200
committerShawn Rutledge <shawn.rutledge@digia.com>2014-08-25 20:42:52 +0200
commit8f547c4252ab687dfd8147b77de2a3c5e8914a84 (patch)
treef4da7d99c1a886339625d411ba001aae77694df1 /src/plugins
parentf9de7efe60f0e6fdec25bb1b59ee59f8ce757490 (diff)
Avoid crash if querying device that has gone away
A device removed very fast after being inserted might disappear while we are still seting it up. We must therefore check if we indeed still get a matching device Task-number: QTBUG-40820 Change-Id: I4372fb1932264e5799f37cea0d016795e28ebed6 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection_xi2.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
index af4ed8e6e6..84d00d0e09 100644
--- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -336,10 +336,12 @@ XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id)
{
XInput2TouchDeviceData *dev = m_touchDevices[id];
if (!dev) {
- int unused = 0;
+ int nrDevices = 0;
QTouchDevice::Capabilities caps = 0;
dev = new XInput2TouchDeviceData;
- dev->xiDeviceInfo = XIQueryDevice(static_cast<Display *>(m_xlib_display), id, &unused);
+ dev->xiDeviceInfo = XIQueryDevice(static_cast<Display *>(m_xlib_display), id, &nrDevices);
+ if (nrDevices <= 0)
+ return 0;
int type = -1;
int maxTouchPoints = 1;
bool hasRelativeCoords = false;