summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-09-24 15:25:32 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-10-03 09:13:56 +0000
commit91d43a48f7307938624d4ab11e488494456646f5 (patch)
tree89c1693b85e69a339409a28c06a8c51ad0894f12
parent4840668994739054f0976d90eebe9ccfdff0ed81 (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>
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp2
-rw-r--r--src/widgets/kernel/qapplication.cpp4
-rw-r--r--src/widgets/kernel/qgesturemanager.cpp2
-rw-r--r--src/widgets/kernel/qgesturemanager_p.h4
-rw-r--r--src/widgets/kernel/qwidget.cpp2
5 files changed, 8 insertions, 6 deletions
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 203b879020..a32f1388bf 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -1598,7 +1598,7 @@ QGraphicsItem::~QGraphicsItem()
#ifndef QT_NO_GESTURES
if (d_ptr->isObject && !d_ptr->gestureContext.isEmpty()) {
QGraphicsObject *o = static_cast<QGraphicsObject *>(this);
- if (QGestureManager *manager = QGestureManager::instance()) {
+ if (QGestureManager *manager = QGestureManager::instance(QGestureManager::DontForceCreation)) {
const auto types = d_ptr->gestureContext.keys(); // FIXME: iterate over the map directly?
for (Qt::GestureType type : types)
manager->cleanupCachedGestures(o, type);
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);