From 970390e11418647efd420001cdabea67ba0c575f Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 21 Aug 2014 12:05:29 -0500 Subject: Incorporate fixes from QQmlAnimationTimer into QAnimationTimer. Incorporates animation timer fixes in: * 7da483bfbefcaabb1dbbf3e2f1d5b5f7aadc3b06 * b02eeeee586abe343b8866385c1327ac009b3ef0 * 59d5c5cf555a51cd7559cea197a198ef3a792614 from qtdeclarative. With these changes, we no longer need to call updateAnimationTimers in QUnifiedTimer::startTimers. Change-Id: Ic24501cfdc3cb572bd891d84f684f11c3bef1b50 Reviewed-by: Gunnar Sletta --- src/corelib/animation/qabstractanimation.cpp | 29 +++++++++++++--------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 8263e056fb..28a09ee2e4 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -392,23 +392,18 @@ void QUnifiedTimer::startTimers() { startTimersPending = false; - // Initialize the wall clock right away as we need this for - // both localRestart and updateAnimationTimers() down below.. - if (!time.isValid()) { - lastTick = 0; - time.start(); - temporalDrift = 0; - driverStartTime = 0; - } - - if (!animationTimers.isEmpty()) - updateAnimationTimers(-1); - //we transfer the waiting animations into the "really running" state animationTimers += animationTimersToStart; animationTimersToStart.clear(); - if (!animationTimers.isEmpty()) + if (!animationTimers.isEmpty()) { + if (!time.isValid()) { + lastTick = 0; + time.start(); + temporalDrift = 0; + driverStartTime = 0; + } localRestart(); + } } void QUnifiedTimer::stopTimer() @@ -642,11 +637,12 @@ void QAnimationTimer::restartAnimationTimer() void QAnimationTimer::startAnimations() { + if (!startAnimationPending) + return; startAnimationPending = false; //force timer to update, which prevents large deltas for our newly added animations - if (!animations.isEmpty()) - QUnifiedTimer::instance()->maybeUpdateAnimationsToCurrentTime(); + QUnifiedTimer::instance()->maybeUpdateAnimationsToCurrentTime(); //we transfer the waiting animations into the "really running" state animations += animationsToStart; @@ -658,7 +654,8 @@ void QAnimationTimer::startAnimations() void QAnimationTimer::stopTimer() { stopTimerPending = false; - if (animations.isEmpty()) { + bool pendingStart = startAnimationPending && animationsToStart.size() > 0; + if (animations.isEmpty() && !pendingStart) { QUnifiedTimer::resumeAnimationTimer(this); QUnifiedTimer::stopAnimationTimer(this); // invalidate the start reference time -- cgit v1.2.3