diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2011-03-16 17:20:32 +1000 |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2011-03-23 16:22:28 +1000 |
commit | 0f5feed7dc260eabe1c2784a168e0b2fcc85e1d8 (patch) | |
tree | 882ecd1f18a962866275cd981889dafbd139c28c /src/corelib | |
parent | b3f605aebb90dc651e73a252788a81cb530a74b9 (diff) |
Fix QUnifiedTimer bug
Pause animations (like Timer) could trigger a jump to the next tick,
which meant that other pause animations would have missed the interval
skipped by the pause.
Change-Id: Idebe4cbe70b2a1536d684288fc1c5d65e4c5df84
Cherry-pick-of: 115d437efb25adc2262460e001c034ea3cd8ba14
Task-number: QTBUG-18126
Reviewed-by: Leo Cunha
Reviewed-by: Michael Brasser
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/animation/qabstractanimation.cpp | 8 | ||||
-rw-r--r-- | src/corelib/animation/qabstractanimation_p.h | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index a562542b52..55e511ddba 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -167,7 +167,7 @@ Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer) QUnifiedTimer::QUnifiedTimer() : QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL), - currentAnimationIdx(0), consistentTiming(false), slowMode(false), + insideTick(false), currentAnimationIdx(0), consistentTiming(false), slowMode(false), slowdownFactor(5.0f), isPauseTimerActive(false), runningLeafAnimations(0) { time.invalidate(); @@ -206,6 +206,10 @@ void QUnifiedTimer::ensureTimerUpdate() void QUnifiedTimer::updateAnimationsTime() { + //setCurrentTime can get this called again while we're the for loop. At least with pauseAnimations + if(insideTick) + return; + qint64 totalElapsed = time.elapsed(); // ignore consistentTiming in case the pause timer is active int delta = (consistentTiming && !isPauseTimerActive) ? @@ -223,12 +227,14 @@ void QUnifiedTimer::updateAnimationsTime() //it might happen in some cases that the time doesn't change because events are delayed //when the CPU load is high if (delta) { + insideTick = true; 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); } + insideTick = false; currentAnimationIdx = 0; } } diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index 2c0eee7206..0ccc502789 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -205,6 +205,7 @@ private: qint64 lastTick; int timingInterval; int currentAnimationIdx; + bool insideTick; bool consistentTiming; bool slowMode; |