summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-08-25 15:36:37 +0200
committerThierry Bastian <thierry.bastian@nokia.com>2009-08-25 15:36:37 +0200
commit48489988521b818bda8d76e60cb272508e91b490 (patch)
treec27861bf42049a62dda5e13b91fa2a5c11a8e6bd /src
parent1cc4ed833f75bc363507bcb7db235bff16785d88 (diff)
animations: make sure setCurrentTime is called on all animations
The problem was we were iterating over the list of running animations. And when calling setCurrentTime(<duration>) on one of them they just unregister themselves from the timer and we would miss some of them. Reviewed-by: leo
Diffstat (limited to 'src')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index efe1fb092..617f4db85 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -200,8 +200,11 @@ void QUnifiedTimer::timerEvent(QTimerEvent *event)
}
} else if (event->timerId() == animationTimer.timerId()) {
const int delta = lastTick - oldLastTick;
- for (int i = 0; i < animations.count(); ++i) {
- QAbstractAnimation *animation = animations.at(i);
+ //we copy the list so that if it is changed we still get to
+ //call setCurrentTime on all animations.
+ const QList<QAbstractAnimation*> currentAnimations = animations;
+ for (int i = 0; i < currentAnimations.count(); ++i) {
+ QAbstractAnimation *animation = currentAnimations.at(i);
int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime
+ (animation->direction() == QAbstractAnimation::Forward ? delta : -delta);
animation->setCurrentTime(elapsed);