diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-11-04 13:06:07 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-11-04 13:08:09 (GMT) |
commit | a1ccc70d07235ac8f0a76c8d2393afc97f968060 (patch) | |
tree | 92d4a1cd58c113ba0d89fdb5e9f00a7935bb0336 | |
parent | 6a89d8fa5ee84188a8921dc387f82593cfed166b (diff) | |
download | Qt-a1ccc70d07235ac8f0a76c8d2393afc97f968060.zip Qt-a1ccc70d07235ac8f0a76c8d2393afc97f968060.tar.gz Qt-a1ccc70d07235ac8f0a76c8d2393afc97f968060.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 7fa3ae3..4f93c1e 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -348,29 +348,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: { @@ -390,15 +387,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)) { |