diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-11-04 13:06:07 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-11-05 23:04:04 (GMT) |
commit | 8ad965ff19490d8c38ff4562f61fa0ca5b33e3e4 (patch) | |
tree | 4924f03517561997146465fe4ae6bfe802ea79d9 | |
parent | 4266b0616bb5d67244173dbe4d9d417dbf4d302f (diff) | |
download | Qt-8ad965ff19490d8c38ff4562f61fa0ca5b33e3e4.zip Qt-8ad965ff19490d8c38ff4562f61fa0ca5b33e3e4.tar.gz Qt-8ad965ff19490d8c38ff4562f61fa0ca5b33e3e4.tar.bz2 |
Fix to the unregistration of the animation to the global timer
The unregistration has to happen befaire calling virtual methods
to support changing the state in those functions.
Reviewed-by: ogoffart
-rw-r--r-- | src/corelib/animation/qabstractanimation.cpp | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 948a084..6ab5bde 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -347,29 +347,26 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) state = newState; QWeakPointer<QAbstractAnimation> guard(q); - q->updateState(oldState, newState); - if (!guard) - return; + //unregistration of the animation must always happen before calls to + //virtual function (updateState) to ensure a correct state of the timer + if (oldState == QAbstractAnimation::Running) { + if (newState == QAbstractAnimation::Paused && hasRegisteredTimer) + QUnifiedTimer::instance()->ensureTimerUpdate(); + //the animation, is not running any more + QUnifiedTimer::instance()->unregisterAnimation(q); + } - //this is to be safe if updateState changes the state - if (state == oldState) + q->updateState(oldState, newState); + if (!guard || newState != state) //this is to be safe if updateState changes the state return; // Notify state change emit q->stateChanged(oldState, newState); - if (!guard) + if (!guard || newState != state) //this is to be safe if updateState changes the state return; switch (state) { case QAbstractAnimation::Paused: - if (hasRegisteredTimer) - // currentTime needs to be updated if pauseTimer is active - QUnifiedTimer::instance()->ensureTimerUpdate(); - if (!guard) - return; - //here we're sure that we were in running state before and that the - //animation is currently registered - QUnifiedTimer::instance()->unregisterAnimation(q); break; case QAbstractAnimation::Running: { @@ -389,15 +386,10 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) case QAbstractAnimation::Stopped: // Leave running state. int dura = q->duration(); - if (!guard) - return; if (deleteWhenStopped) q->deleteLater(); - if (oldState == QAbstractAnimation::Running) - QUnifiedTimer::instance()->unregisterAnimation(q); - if (dura == -1 || loopCount < 0 || (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount)) || (oldDirection == QAbstractAnimation::Backward && oldCurrentTime == 0)) { |