summaryrefslogtreecommitdiffstats
path: root/src/corelib/animation/qabstractanimation.cpp
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-10-21 08:49:42 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-10-21 08:49:42 (GMT)
commita072ddb5072d837ff6d2ff1f09800e8e3917f034 (patch)
tree89e42c12b79ebb38923ebf6ae9d340f7098f306e /src/corelib/animation/qabstractanimation.cpp
parent619d049371ac8a180de3d91140bf252f44c25dad (diff)
downloadQt-a072ddb5072d837ff6d2ff1f09800e8e3917f034.zip
Qt-a072ddb5072d837ff6d2ff1f09800e8e3917f034.tar.gz
Qt-a072ddb5072d837ff6d2ff1f09800e8e3917f034.tar.bz2
Fixes to the way animations are registered to the timer
It could happen that an animation would be unregistered when it shouldn't. Reviewed-by: Leo Cunha
Diffstat (limited to 'src/corelib/animation/qabstractanimation.cpp')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 2f776d3..f83c2a1 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -279,11 +279,11 @@ void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation, bool isTopL
void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation)
{
+ unregisterRunningAnimation(animation);
+
if (!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer)
return;
- unregisterRunningAnimation(animation);
-
int idx = animations.indexOf(animation);
if (idx != -1) {
animations.removeAt(idx);
@@ -384,25 +384,20 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
QUnifiedTimer::instance()->ensureTimerUpdate(q);
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:
{
bool isTopLevel = !group || group->state() == QAbstractAnimation::Stopped;
+ QUnifiedTimer::instance()->registerAnimation(q, isTopLevel);
// this ensures that the value is updated now that the animation is running
if (oldState == QAbstractAnimation::Stopped) {
if (isTopLevel)
// currentTime needs to be updated if pauseTimer is active
QUnifiedTimer::instance()->ensureTimerUpdate(q);
- if (!guard)
- return;
- }
-
- // test needed in case we stop in the setCurrentTime inside ensureTimerUpdate (zero duration)
- if (state == QAbstractAnimation::Running) {
- // register timer if our parent is not running
- QUnifiedTimer::instance()->registerAnimation(q, isTopLevel);
}
}
break;
@@ -415,7 +410,8 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
if (deleteWhenStopped)
q->deleteLater();
- QUnifiedTimer::instance()->unregisterAnimation(q);
+ if (oldState == QAbstractAnimation::Running)
+ QUnifiedTimer::instance()->unregisterAnimation(q);
if (dura == -1 || loopCount < 0
|| (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount))
@@ -462,7 +458,8 @@ QAbstractAnimation::~QAbstractAnimation()
QAbstractAnimation::State oldState = d->state;
d->state = Stopped;
emit stateChanged(oldState, d->state);
- QUnifiedTimer::instance()->unregisterAnimation(this);
+ if (oldState == QAbstractAnimation::Running)
+ QUnifiedTimer::instance()->unregisterAnimation(this);
}
}