diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-09-24 15:25:32 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-10-03 09:13:56 +0000 |
commit | 91d43a48f7307938624d4ab11e488494456646f5 (patch) | |
tree | 89c1693b85e69a339409a28c06a8c51ad0894f12 /src/widgets/kernel | |
parent | 4840668994739054f0976d90eebe9ccfdff0ed81 (diff) |
Prevent instantiation of QGestureManager in ~QWidget, ~QGraphicsItem()
Debugging PYSIDE-815 revealed that QGestureManager is instantiated in
the application destruction sequence. To prevent that, add a "force"
parameter defaulting to true to QGestureManager::instance() and pass
false in the destructors and QGestureManager::gesturePending().
Change-Id: I1b76173c926c2a156252b88832b032508d8e8a73
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 4 | ||||
-rw-r--r-- | src/widgets/kernel/qgesturemanager.cpp | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qgesturemanager_p.h | 4 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 2 |
4 files changed, 7 insertions, 5 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 10ded6e34f..45b98e9475 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -4521,12 +4521,12 @@ void QApplicationPrivate::notifyDragStarted(const QDrag *drag) #endif // QT_CONFIG(draganddrop) #ifndef QT_NO_GESTURES -QGestureManager* QGestureManager::instance() +QGestureManager* QGestureManager::instance(InstanceCreation ic) { QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); if (!qAppPriv) return 0; - if (!qAppPriv->gestureManager) + if (!qAppPriv->gestureManager && ic == ForceCreation) qAppPriv->gestureManager = new QGestureManager(qApp); return qAppPriv->gestureManager; } diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index 5bf66d68e3..c4188044cf 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -773,7 +773,7 @@ void QGestureManager::recycle(QGesture *gesture) bool QGestureManager::gesturePending(QObject *o) { - const QGestureManager *gm = QGestureManager::instance(); + const QGestureManager *gm = QGestureManager::instance(DontForceCreation); return gm && gm->m_gestureOwners.key(o); } diff --git a/src/widgets/kernel/qgesturemanager_p.h b/src/widgets/kernel/qgesturemanager_p.h index 3df80bab55..3a5c9822eb 100644 --- a/src/widgets/kernel/qgesturemanager_p.h +++ b/src/widgets/kernel/qgesturemanager_p.h @@ -81,7 +81,9 @@ public: bool filterEvent(QGraphicsObject *receiver, QEvent *event); #endif // QT_CONFIG(graphicsview) - static QGestureManager* instance(); // declared in qapplication.cpp + enum InstanceCreation { ForceCreation, DontForceCreation }; + + static QGestureManager *instance(InstanceCreation ic = ForceCreation); // declared in qapplication.cpp static bool gesturePending(QObject *o); void cleanupCachedGestures(QObject *target, Qt::GestureType type); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index a1a861e216..09a08fac14 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1572,7 +1572,7 @@ QWidget::~QWidget() #endif #ifndef QT_NO_GESTURES - if (QGestureManager *manager = QGestureManager::instance()) { + if (QGestureManager *manager = QGestureManager::instance(QGestureManager::DontForceCreation)) { // \forall Qt::GestureType type : ungrabGesture(type) (inlined) for (auto it = d->gestureContext.keyBegin(), end = d->gestureContext.keyEnd(); it != end; ++it) manager->cleanupCachedGestures(this, *it); |