From de6380c8da3e22d30b0ec292da8da1db96d721ef Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 21 Sep 2009 14:15:17 +0200 Subject: 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. --- src/corelib/animation/qabstractanimation.cpp | 18 +++++++++++------- 1 file 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; } } -- cgit v0.12