Emit runningChanged() signal after running count updated
authorCharles Yin <charles.yin@nokia.com>
Wed, 9 May 2012 00:24:06 +0000 (10:24 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 9 May 2012 01:26:54 +0000 (03:26 +0200)
Otherwise, in onRunningChanged handler, the running property won't
be updated.

Change-Id: I3dccfb346a66c67d455f66f4af3ee8d2b9d8e33a
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
src/quick/util/qquicktransition.cpp
tests/auto/quick/qquickanimations/tst_qquickanimations.cpp

index 300dda1..b885849 100644 (file)
@@ -175,12 +175,12 @@ void QQuickTransitionPrivate::animationStateChanged(QAbstractAnimationJob *, QAb
     Q_Q(QQuickTransition);
 
     if (newState == QAbstractAnimationJob::Running) {
-        if (!runningInstanceCount)
-            emit q->runningChanged();
         runningInstanceCount++;
+        if (runningInstanceCount == 1)
+            emit q->runningChanged();
     } else if (newState == QAbstractAnimationJob::Stopped) {
         runningInstanceCount--;
-        if (!runningInstanceCount)
+        if (runningInstanceCount == 0)
             emit q->runningChanged();
     }
 }
index 7460263..60b0465 100644 (file)
@@ -990,9 +990,12 @@ void tst_qquickanimations::disabledTransition()
     QSignalSpy runningSpy(trans, SIGNAL(runningChanged()));
     QQuickItemPrivate::get(rect)->setState("");
     QCOMPARE(myRect->x(),qreal(200));
+    QCOMPARE(runningSpy.count(), 1); //stopped -> running
+    QVERIFY(trans->running());
     QTest::qWait(300);
     QTIMED_COMPARE(myRect->x(),qreal(100));
-    QCOMPARE(runningSpy.count(), 2); //stopped, running, stopped
+    QVERIFY(!trans->running());
+    QCOMPARE(runningSpy.count(), 2); //running -> stopped
 }
 
 void tst_qquickanimations::invalidDuration()