summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qgesturemanager.cpp10
-rw-r--r--src/gui/kernel/qgesturemanager_p.h1
-rw-r--r--tests/auto/gestures/tst_gestures.cpp4
3 files changed, 12 insertions, 3 deletions
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp
index 5e9a0cb..9519447 100644
--- a/src/gui/kernel/qgesturemanager.cpp
+++ b/src/gui/kernel/qgesturemanager.cpp
@@ -175,9 +175,9 @@ void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType typ
m_activeGestures.remove(g);
m_gestureOwners.remove(g);
m_gestureTargets.remove(g);
+ m_gesturesToDelete.insert(g);
}
- qDeleteAll(gestures);
iter = m_objectGestures.erase(iter);
} else {
++iter;
@@ -385,6 +385,11 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap<QObject *,
recycle(gesture);
m_gestureTargets.remove(gesture);
}
+
+ //Clean up the Gestures
+ qDeleteAll(m_gesturesToDelete);
+ m_gesturesToDelete.clear();
+
return ret;
}
@@ -447,7 +452,8 @@ void QGestureManager::cancelGesturesForChildren(QGesture *original)
void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture)
{
QGestureRecognizer *recognizer = m_deletedRecognizers.value(gesture);
- Q_ASSERT(recognizer);
+ if(!recognizer) //The Gesture is removed while in the even loop, so the recognizers for this gestures was removed
+ return;
m_deletedRecognizers.remove(gesture);
if (m_deletedRecognizers.keys(recognizer).isEmpty()) {
// no more active gestures, cleanup!
diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h
index 0d84b67..a5a3482 100644
--- a/src/gui/kernel/qgesturemanager_p.h
+++ b/src/gui/kernel/qgesturemanager_p.h
@@ -130,6 +130,7 @@ private:
QHash<QGestureRecognizer *, QSet<QGesture *> > m_obsoleteGestures;
QHash<QGesture *, QGestureRecognizer *> m_deletedRecognizers;
+ QSet<QGesture *> m_gesturesToDelete;
void cleanupGesturesForRemovedRecognizer(QGesture *gesture);
QGesture *getState(QObject *widget, QGestureRecognizer *recognizer,
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp
index 667cdd3..ee19125 100644
--- a/tests/auto/gestures/tst_gestures.cpp
+++ b/tests/auto/gestures/tst_gestures.cpp
@@ -1486,13 +1486,15 @@ void tst_Gestures::ungrabGesture() // a method on QWidget
QVERIFY(customGestureA.data() != customGestureB.data());
a->ungrabGesture(CustomGesture::GestureType);
- QVERIFY(customGestureA.isNull());
+ //We changed the deletion of Gestures to lazy during QT-4022, so we can't ensure the QGesture is deleted until now
QVERIFY(!customGestureB.isNull());
a->gestures.clear();
a->reset();
// send again to 'b' and make sure a never gets it.
sendCustomGesture(&event, b);
+ //After all Gestures are processed in the QGestureManager, we can ensure the QGesture is now deleted
+ QVERIFY(customGestureA.isNull());
QCOMPARE(a->gestureEventsReceived, 0);
QCOMPARE(a->gestureOverrideEventsReceived, 0);
}