From 5fe98ebb376bcbc8728e4ce64b697637404a55e1 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Sun, 6 Apr 2014 20:00:07 -0500 Subject: Prevent QUnifiedTimer from ticking backwards. This could happen in the following situation: * a custom animation driver with fixed delta * a triple-buffering scheme (rendering ahead a frame) * a second animation timer starting while a first was active This would cause QUnifiedTimer::startTimers() to trigger QUnifiedTimer::updateAnimationTimers(-1), and use the current time from the QElapsedTimer rather than the animation driver. This time could be less than the last reported time from the animation driver. Change-Id: Ibf1796fcb99f288d4946b30e5e7225695aa61781 Reviewed-by: Gunnar Sletta --- src/corelib/animation/qabstractanimation.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 139876de3a..f7bb1e91bd 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -277,10 +277,12 @@ void QUnifiedTimer::updateAnimationTimers(qint64 currentTick) lastTick = totalElapsed; - //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 (delta) { + //we make sure we only call update time if the time has actually advanced + //* it might happen in some cases that the time doesn't change because events are delayed + // when the CPU load is high + //* it might happen in some cases that the delta is negative because the animation driver + // advances faster than time.elapsed() + if (delta > 0) { insideTick = true; if (profilerCallback) profilerCallback(delta); -- cgit v1.2.3