From: Charles Yin Date: Wed, 9 May 2012 06:01:51 +0000 (+1000) Subject: More defense programming in animation code X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=8236ca1aedabccf4bda4d0e3873ace8b48c522d6;p=konrad%2Fqtdeclarative.git More defense programming in animation code 1. Add more deletion checkings in animation job code 2. Add some more asserts Change-Id: I34772792ea4638b61eb2c3d65da5d35ce75183d7 Reviewed-by: Michael Brasser --- diff --git a/src/qml/animations/qabstractanimationjob.cpp b/src/qml/animations/qabstractanimationjob.cpp index d1b8880..285937d 100644 --- a/src/qml/animations/qabstractanimationjob.cpp +++ b/src/qml/animations/qabstractanimationjob.cpp @@ -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)); } } }