From f5adbaa903d5ac078dc71d5af555ba7884645a8f Mon Sep 17 00:00:00 2001
From: Martin Jones <martin.jones@jollamobile.com>
Date: Wed, 2 Jul 2014 02:12:05 +0000
Subject: [PATCH] Fix crash in Flickable with pressDelay.

Looks like this was exposed by the touch event compression change.

Task-number: QTBUG-40000
Change-Id: I037c848e0c5d766857dff3162c244213aba847da
Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
---
 src/quick/items/qquickflickable.cpp | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index d1bad78d41..d12a7554bb 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -1374,15 +1374,15 @@ void QQuickFlickablePrivate::replayDelayedPress()
         delayedPressTimer.stop();
 
         // If we have the grab, release before delivering the event
-        QQuickWindow *w = q->window();
-        if (w && (w->mouseGrabberItem() == q)) {
-            q->ungrabMouse();
+        if (QQuickWindow *w = q->window()) {
+            if (w->mouseGrabberItem() == q)
+                q->ungrabMouse();
+
+            // Use the event handler that will take care of finding the proper item to propagate the event
+            replayingPressEvent = true;
+            QQuickWindowPrivate::get(w)->deliverMouseEvent(mouseEvent.data());
+            replayingPressEvent = false;
         }
-
-        // Use the event handler that will take care of finding the proper item to propagate the event
-        replayingPressEvent = true;
-        QQuickWindowPrivate::get(w)->deliverMouseEvent(mouseEvent.data());
-        replayingPressEvent = false;
     }
 }
 
-- 
GitLab