More defense programming in animation code
authorCharles Yin <charles.yin@nokia.com>
Wed, 9 May 2012 06:01:51 +0000 (16:01 +1000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 17 May 2012 04:44:33 +0000 (06:44 +0200)
1. Add more deletion checkings in animation job code
2. Add some more asserts

Change-Id: I34772792ea4638b61eb2c3d65da5d35ce75183d7
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>

src/qml/animations/qabstractanimationjob.cpp

index d1b8880..285937d 100644 (file)
@@ -284,8 +284,11 @@ QAbstractAnimationJob::~QAbstractAnimationJob()
         State oldState = m_state;
         m_state = Stopped;
         stateChanged(oldState, m_state);
+
+        Q_ASSERT(m_state == Stopped);
         if (oldState == Running)
             QQmlAnimationTimer::unregisterAnimation(this);
+        Q_ASSERT(!m_hasRegisteredTimer);
     }
 
     if (m_group)
@@ -337,7 +340,7 @@ void QAbstractAnimationJob::setState(QAbstractAnimationJob::State newState)
         return;
 
     // Notify state change
-    stateChanged(newState, oldState);
+    RETURN_IF_DELETED(stateChanged(newState, oldState));
     if (newState != m_state) //this is to be safe if updateState changes the state
         return;
 
@@ -351,7 +354,7 @@ void QAbstractAnimationJob::setState(QAbstractAnimationJob::State newState)
                 if (isTopLevel) {
                     // currentTime needs to be updated if pauseTimer is active
                     QQmlAnimationTimer::ensureTimerUpdate();
-                    setCurrentTime(m_totalCurrentTime);
+                    RETURN_IF_DELETED(setCurrentTime(m_totalCurrentTime));
                 }
             }
         }