diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2010-01-06 17:16:27 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2010-01-07 09:52:29 (GMT) |
commit | 828b1299e1ecb2da23799a2e49370e00dcf9c126 (patch) | |
tree | 6bbb15ada48bfbaf71f36c5c28e2d94c96d4b180 /src/gui/kernel | |
parent | 089ee7094eabb2058b478f5d2f306a69f6c0b3bf (diff) | |
download | Qt-828b1299e1ecb2da23799a2e49370e00dcf9c126.zip Qt-828b1299e1ecb2da23799a2e49370e00dcf9c126.tar.gz Qt-828b1299e1ecb2da23799a2e49370e00dcf9c126.tar.bz2 |
Fixes a crash when destroying and creating QApplication.
Moved the gestureManager pointer to a QApplicationPrivate to make sure if
QApplication object is destroyed, QGestureManager pointer is set to zero.
Task-number: QTBUG-7029
Reviewed-by: Thiago
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qapplication.cpp | 15 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_p.h | 2 | ||||
-rw-r--r-- | src/gui/kernel/qgesturemanager.cpp | 9 | ||||
-rw-r--r-- | src/gui/kernel/qgesturemanager_p.h | 4 |
4 files changed, 15 insertions, 15 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 79fd3ad..12fe797 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -177,6 +177,7 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::T directPainters = 0; #endif + gestureManager = 0; gestureWidget = 0; if (!self) @@ -3632,7 +3633,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) } // walk through parents and check for gestures - if (qt_gestureManager) { + if (d->gestureManager) { switch (e->type()) { case QEvent::Paint: case QEvent::MetaCall: @@ -3664,13 +3665,13 @@ bool QApplication::notify(QObject *receiver, QEvent *e) break; default: if (receiver->isWidgetType()) { - if (qt_gestureManager->filterEvent(static_cast<QWidget *>(receiver), e)) + if (d->gestureManager->filterEvent(static_cast<QWidget *>(receiver), e)) return true; } else { // a special case for events that go to QGesture objects. // We pass the object to the gesture manager and it'll figure // out if it's QGesture or not. - if (qt_gestureManager->filterEvent(receiver, e)) + if (d->gestureManager->filterEvent(receiver, e)) return true; } } @@ -5678,6 +5679,14 @@ Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window, QApplicationPrivate::translateRawTouchEvent(window, deviceType, touchPoints); } +QGestureManager* QGestureManager::instance() +{ + QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); + if (!qAppPriv->gestureManager) + qAppPriv->gestureManager = new QGestureManager(qApp); + return qAppPriv->gestureManager; +} + QT_END_NAMESPACE #include "moc_qapplication.cpp" diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index e23b5bc..f8943a8 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -84,6 +84,7 @@ class QInputContext; class QObject; class QWidget; class QSocketNotifier; +class QGestureManager; extern bool qt_is_gui_used; #ifndef QT_NO_CLIPBOARD @@ -509,6 +510,7 @@ public: void sendSyntheticEnterLeave(QWidget *widget); #endif + QGestureManager *gestureManager; QWidget *gestureWidget; QMap<int, QWeakPointer<QWidget> > widgetForTouchPointId; diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index f642938..89ad94d 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -67,15 +67,6 @@ QT_BEGIN_NAMESPACE -QGestureManager *qt_gestureManager = 0; - -QGestureManager* QGestureManager::instance() -{ - if (!qt_gestureManager) - qt_gestureManager = new QGestureManager(qApp); - return qt_gestureManager; -} - QGestureManager::QGestureManager(QObject *parent) : QObject(parent), state(NotGesture), m_lastCustomGestureId(0) { diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index 06dcc3e..a0ff83f 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -78,7 +78,7 @@ public: bool filterEvent(QGraphicsObject *receiver, QEvent *event); #endif //QT_NO_GRAPHICSVIEW - static QGestureManager* instance(); + static QGestureManager* instance(); // declared in qapplication.cpp void cleanupCachedGestures(QObject *target, Qt::GestureType type); @@ -142,8 +142,6 @@ private: void cancelGesturesForChildren(QGesture *originatingGesture); }; -extern QGestureManager *qt_gestureManager; - QT_END_NAMESPACE #endif // QGESTUREMANAGER_P_H |