diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-08-25 13:36:37 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-08-25 13:36:37 (GMT) |
commit | 48489988521b818bda8d76e60cb272508e91b490 (patch) | |
tree | c27861bf42049a62dda5e13b91fa2a5c11a8e6bd /src | |
parent | 1cc4ed833f75bc363507bcb7db235bff16785d88 (diff) | |
download | Qt-48489988521b818bda8d76e60cb272508e91b490.zip Qt-48489988521b818bda8d76e60cb272508e91b490.tar.gz Qt-48489988521b818bda8d76e60cb272508e91b490.tar.bz2 |
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.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index efe1fb0..617f4db 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); |