File libqt5-avoid-crash-during-querying-device.patch of Package libqt5-qtbase

From f1bce3bc17ebb99b1512b07499988538465c78a2 Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@digia.com>
Date: Thu, 21 Aug 2014 15:33:09 +0200
Subject: [PATCH] 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: Shawn Rutledge <shawn.rutledge@digia.com>
---
 src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

--- qtbase-opensource-src-5.3.1.orig/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
+++ qtbase-opensource-src-5.3.1/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
@@ -328,10 +328,12 @@ XInput2DeviceData *QXcbConnection::devic
 {
     XInput2DeviceData *dev = m_touchDevices[id];
     if (!dev) {
-        int unused = 0;
+        int nrDevices = 0;
         QTouchDevice::Capabilities caps = 0;
         dev = new XInput2DeviceData;
-        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;
openSUSE Build Service is sponsored by