path: root/src/widgets/kernel/qmacgesturerecognizer_p.h
diff options
authorJan Arve Saether <>2018-04-23 11:39:56 +0200
committerJan Arve Sæther <>2018-05-02 09:16:22 +0000
commitc1ead32a84db96fd1b48e47d81511adf64cfe410 (patch)
treeb577cf4984b00e9aaf8c4fce901e6552721d1f59 /src/widgets/kernel/qmacgesturerecognizer_p.h
parent364bd6ca74b059ffe8ae367e1562645a3ed0855e (diff)
Fix crash in QMacPanGestureRecognizer
The reason it crashed was this: 1. Button was pressed => _panTimer started with the graphics view as destination. 2. Button was released => the graphicsview is destroyed 3. 300 ms later: Qt tries to deliver TimerEvent from _panTimer to the graphics view. Unfortunately, the graphics view is deleted, but Qt doesn't know that... (*crash*) We therefore chose to start the timer with a destination we are controlling the lifetime of: the QMacPanGestureRecognizer. Inside the timerEvent of that we can check if the actual target is already destroyed. Task-number: QTBUG-60404 Change-Id: Iff8f5b7217de42c4c5cf551ca507f0cff1c99a78 Reviewed-by: Frederik Gladhorn <>
Diffstat (limited to 'src/widgets/kernel/qmacgesturerecognizer_p.h')
1 files changed, 4 insertions, 0 deletions
diff --git a/src/widgets/kernel/qmacgesturerecognizer_p.h b/src/widgets/kernel/qmacgesturerecognizer_p.h
index be3f3266ac..e381a6cc2f 100644
--- a/src/widgets/kernel/qmacgesturerecognizer_p.h
+++ b/src/widgets/kernel/qmacgesturerecognizer_p.h
@@ -55,6 +55,7 @@
#include "qtimer.h"
#include "qpoint.h"
#include "qgesturerecognizer.h"
+#include <QtCore/qpointer.h>
@@ -88,10 +89,13 @@ public:
QGesture *create(QObject *target);
QGestureRecognizer::Result recognize(QGesture *gesture, QObject *watched, QEvent *event);
void reset(QGesture *gesture);
+ void timerEvent(QTimerEvent *ev) override;
QPointF _startPos;
QBasicTimer _panTimer;
bool _panCanceled;
+ QPointer<QObject> _target;