diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-09-21 12:15:17 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-09-22 13:30:19 (GMT) |
commit | de6380c8da3e22d30b0ec292da8da1db96d721ef (patch) | |
tree | 1d0a9ba30860e469baca5e5de5e26fdd03a857dd /src/corelib/animation | |
parent | 6a17647e7ac5a498f8495de434b946632172f291 (diff) | |
download | Qt-de6380c8da3e22d30b0ec292da8da1db96d721ef.zip Qt-de6380c8da3e22d30b0ec292da8da1db96d721ef.tar.gz Qt-de6380c8da3e22d30b0ec292da8da1db96d721ef.tar.bz2 |
Fix a possible warning on animations used with states
The problem is that sometimes timerevents get compressed. So in the
unified timer, we need to make sure that some time has passed between 2
ticks.
Diffstat (limited to 'src/corelib/animation')
-rw-r--r-- | src/corelib/animation/qabstractanimation.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 3d3eafd..6306882 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -214,14 +214,18 @@ void QUnifiedTimer::timerEvent(QTimerEvent *event) time.start(); } } else if (event->timerId() == animationTimer.timerId()) { - const int delta = lastTick - oldLastTick; - for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) { - QAbstractAnimation *animation = animations.at(currentAnimationIdx); - int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime - + (animation->direction() == QAbstractAnimation::Forward ? delta : -delta); - animation->setCurrentTime(elapsed); + //we make sure we only call update time if the time has actually changed + //it might happen in some cases that the time doesn't change because events are delayed + //when the CPU load is high + if (const int delta = lastTick - oldLastTick) { + for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) { + QAbstractAnimation *animation = animations.at(currentAnimationIdx); + int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime + + (animation->direction() == QAbstractAnimation::Forward ? delta : -delta); + animation->setCurrentTime(elapsed); + } + currentAnimationIdx = 0; } - currentAnimationIdx = 0; } } |