Reset transitioner pointer when transition job finishes
authorBea Lam <bea.lam@nokia.com>
Thu, 8 Mar 2012 07:05:07 +0000 (17:05 +1000)
committerQt by Nokia <qt-info@nokia.com>
Fri, 9 Mar 2012 10:03:23 +0000 (11:03 +0100)
A transition job should only keep a reference to the transitioner
for the lifetime of the transition.

Change-Id: I22564d7b6587fed58ef53fd50ad4a700340dc7a4
Reviewed-by: Martin Jones
Reviewed-by: Martin Jones <martin.jones@nokia.com>
src/quick/items/qquickitemviewtransition.cpp

index 5669ef9..2134c8e 100644 (file)
@@ -62,6 +62,7 @@ public:
     QPointF m_toPos;
     QQuickItemViewTransitioner::TransitionType m_type;
     bool m_isTarget;
+    bool *m_wasDeleted;
 
 protected:
     virtual void finished();
@@ -73,11 +74,14 @@ QQuickItemViewTransitionJob::QQuickItemViewTransitionJob()
     , m_item(0)
     , m_type(QQuickItemViewTransitioner::NoTransition)
     , m_isTarget(false)
+    , m_wasDeleted(0)
 {
 }
 
 QQuickItemViewTransitionJob::~QQuickItemViewTransitionJob()
 {
+    if (m_wasDeleted)
+        *m_wasDeleted = true;
     if (m_transitioner)
         m_transitioner->runningJobs.remove(this);
 }
@@ -134,8 +138,16 @@ void QQuickItemViewTransitionJob::finished()
 {
     QQuickTransitionManager::finished();
 
-    if (m_transitioner)
+    if (m_transitioner) {
+        bool deleted = false;
+        m_wasDeleted = &deleted;
         m_transitioner->finishedTransition(this, m_item);
+        if (deleted)
+            return;
+        m_wasDeleted = 0;
+
+        m_transitioner = 0;
+    }
 
     m_item = 0;
     m_toPos.setX(0);