Reset loop counters when animations are started.
authorGunnar Sletta <gunnar.sletta@jollamobile.com>
Tue, 22 Apr 2014 14:24:06 +0000 (16:24 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 24 Apr 2014 11:46:52 +0000 (13:46 +0200)
Where normal animations would derive the current loop from the current
time, uncontrolled animations use an iterative approach and which was
not reset when an animation was restarted or a parent had a loop
around it.

Change-Id: Ia7a1880c8b7578463dff4c5ddeab48324bcb32ee
Reviewed-by: Michael Brasser <michael.brasser@live.com>
src/qml/animations/qabstractanimationjob.cpp
src/qml/animations/qparallelanimationgroupjob.cpp

index 0928c0e..991b1fa 100644 (file)
@@ -380,6 +380,7 @@ void QAbstractAnimationJob::setState(QAbstractAnimationJob::State newState)
         {
             // this ensures that the value is updated now that the animation is running
             if (oldState == Stopped) {
+                m_currentLoop = 0;
                 if (isTopLevel) {
                     // currentTime needs to be updated if pauseTimer is active
                     RETURN_IF_DELETED(QQmlAnimationTimer::ensureTimerUpdate());
index f66d4b1..f3ea389 100644 (file)
@@ -142,8 +142,10 @@ void QParallelAnimationGroupJob::updateState(QAbstractAnimationJob::State newSta
         break;
     case Running:
         for (QAbstractAnimationJob *animation = firstChild(); animation; animation = animation->nextSibling()) {
-            if (oldState == Stopped)
+            if (oldState == Stopped) {
                 animation->stop();
+                m_previousLoop = m_direction == Forward ? 0 : m_loopCount - 1;
+            }
             resetUncontrolledAnimationFinishTime(animation);
             animation->setDirection(m_direction);
             if (shouldAnimationStart(animation, oldState == Stopped))