diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index c4188044cf..891858b035 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -143,11 +143,6 @@ Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *r void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) { QList list = m_recognizers.values(type); - while (QGestureRecognizer *recognizer = m_recognizers.take(type)) { - // ensuring an entry exists causes the recognizer to be deleted on destruction of the manager - auto &gestures = m_obsoleteGestures[recognizer]; - Q_UNUSED(gestures); - } foreach (QGesture *g, m_gestureToRecognizer.keys()) { QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g); if (list.contains(recognizer)) { diff --git a/src/widgets/kernel/qgesturerecognizer.cpp b/src/widgets/kernel/qgesturerecognizer.cpp index 65c46a5e56..75d091ce4e 100644 --- a/src/widgets/kernel/qgesturerecognizer.cpp +++ b/src/widgets/kernel/qgesturerecognizer.cpp @@ -41,6 +41,7 @@ #include "private/qgesture_p.h" #include "private/qgesturemanager_p.h" +#include "private/qapplication_p.h" #ifndef QT_NO_GESTURES @@ -231,6 +232,11 @@ Qt::GestureType QGestureRecognizer::registerRecognizer(QGestureRecognizer *recog */ void QGestureRecognizer::unregisterRecognizer(Qt::GestureType type) { + auto qAppPriv = QApplicationPrivate::instance(); + if (!qAppPriv) + return; + if (!qAppPriv->gestureManager) + return; QGestureManager::instance()->unregisterGestureRecognizer(type); }