From c1ead32a84db96fd1b48e47d81511adf64cfe410 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Mon, 23 Apr 2018 11:39:56 +0200 Subject: 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 --- src/widgets/kernel/qmacgesturerecognizer_p.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/widgets/kernel/qmacgesturerecognizer_p.h') 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 #ifndef QT_NO_GESTURES @@ -88,10 +89,13 @@ public: QGesture *create(QObject *target); QGestureRecognizer::Result recognize(QGesture *gesture, QObject *watched, QEvent *event); void reset(QGesture *gesture); +protected: + void timerEvent(QTimerEvent *ev) override; private: QPointF _startPos; QBasicTimer _panTimer; bool _panCanceled; + QPointer _target; }; QT_END_NAMESPACE -- cgit v1.2.3