From 81644d683c0c8da3f14f162e31bc55038cb121d7 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Tue, 17 Aug 2010 12:56:57 +0200 Subject: Fix memory leak in gesture manager If the user unregisters a recognizer before anyone ever used it we didn't delete it on application exit. This fix makes sure we do. Task: QTBUG-12845 Reviewed-by: Denis Dzyubenko --- src/gui/kernel/qgesturemanager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index fe9dd8a..e768a21 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -129,7 +129,12 @@ Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *r void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) { QList list = m_recognizers.values(type); - m_recognizers.remove(type); + while (QGestureRecognizer *recognizer = m_recognizers.take(type)) { + if (!m_obsoleteGestures.contains(recognizer)) { + // inserting even an empty QSet will cause the recognizer to be deleted on destruction of the manager + m_obsoleteGestures.insert(recognizer, QSet()); + } + } foreach (QGesture *g, m_gestureToRecognizer.keys()) { QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g); if (list.contains(recognizer)) { -- cgit v0.12