diff options
author | Dominik Holland <dominik.holland@nokia.com> | 2010-09-07 08:31:41 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2010-09-07 08:33:51 (GMT) |
commit | 201e4927f9e23150f460e711a2859dbff3e1353c (patch) | |
tree | fd58d1c1a92eb49ee866a933b7a7c54ac25d7c55 /src/gui | |
parent | 854a274d7b17277235acc1fb3c36f576c7c6b8ec (diff) | |
download | Qt-201e4927f9e23150f460e711a2859dbff3e1353c.zip Qt-201e4927f9e23150f460e711a2859dbff3e1353c.tar.gz Qt-201e4927f9e23150f460e711a2859dbff3e1353c.tar.bz2 |
Replaced QWeakPointer to *Pointer in QGestureManager.
The QWeakPointer was part of a key in a QMap. When the QWeakPointer gets deleted,
the key changes and the sorting of the Map was wrong. That leads to an random crash.
It should be safe not to use QWeakPointer as we remove pointers from the
objectGestures map when a widget or graphicsitem gets destroyed.
Reviewed-by: Denis Dzyubenko
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qgesturemanager.cpp | 3 | ||||
-rw-r--r-- | src/gui/kernel/qgesturemanager_p.h | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index cb4061e..5c80340 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -162,7 +162,7 @@ void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType typ QMap<ObjectGesture, QList<QGesture *> >::Iterator iter = m_objectGestures.begin(); while (iter != m_objectGestures.end()) { ObjectGesture objectGesture = iter.key(); - if (objectGesture.gesture == type && target == objectGesture.object.data()) { + if (objectGesture.gesture == type && target == objectGesture.object) { QSet<QGesture *> gestures = iter.value().toSet(); for (QHash<QGestureRecognizer *, QSet<QGesture *> >::iterator it = m_obsoleteGestures.begin(), e = m_obsoleteGestures.end(); it != e; ++it) { @@ -172,6 +172,7 @@ void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType typ m_deletedRecognizers.remove(g); m_gestureToRecognizer.remove(g); } + qDeleteAll(gestures); iter = m_objectGestures.erase(iter); } else { diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index 747cb1a..0d84b67 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -106,13 +106,13 @@ private: struct ObjectGesture { - QWeakPointer<QObject> object; + QObject* object; Qt::GestureType gesture; ObjectGesture(QObject *o, const Qt::GestureType &g) : object(o), gesture(g) { } inline bool operator<(const ObjectGesture &rhs) const { - if (object.data() < rhs.object.data()) + if (object < rhs.object) return true; if (object == rhs.object) return gesture < rhs.gesture; |