Don't start running if a frame property is set
authorAlan Alpert <alan.alpert@nokia.com>
Wed, 13 Jun 2012 08:49:12 +0000 (18:49 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 20 Jun 2012 04:04:01 +0000 (06:04 +0200)
This fixes an error where running couldn't be reliably set, if a frame
property was also being set during initialization. With this fixed, the
autotest is no longer unstable.

Also fixed is a related issue where start/stop/restart were active
before componentComplete.

Change-Id: I34c6d872f2f146d38c65167eda8c0a97525d7f4e
Reviewed-by: Yann Bodson <yann.bodson@nokia.com>
src/quick/items/qquickanimatedsprite.cpp
src/quick/items/qquickanimatedsprite_p.h
tests/auto/quick/qquickanimatedsprite/qquickanimatedsprite.pro

index acb3886..79a8d00 100644 (file)
@@ -400,7 +400,8 @@ void QQuickAnimatedSprite::componentComplete()
 
 void QQuickAnimatedSprite::start()
 {
-    if (m_running)
+    m_running = true;
+    if (!isComponentComplete())
         return;
     m_curLoop = 0;
     m_timestamp.start();
@@ -409,16 +410,16 @@ void QQuickAnimatedSprite::start()
         m_spriteEngine->updateSprites(0);
         m_spriteEngine->start(0);
     }
-    m_running = true;
+    emit currentFrameChanged(0);
     emit runningChanged(true);
     update();
 }
 
 void QQuickAnimatedSprite::stop()
 {
-    if (!m_running)
-        return;
     m_running = false;
+    if (!isComponentComplete())
+        return;
     m_pauseOffset = 0;
     emit runningChanged(false);
 }
index 4d9c008..0e5ccc2 100644 (file)
@@ -250,7 +250,8 @@ public slots:
         if (m_sprite->m_frameSync != arg) {
             m_sprite->setFrameSync(arg);
             emit frameSyncChanged(arg);
-            restart();
+            if (m_running)
+                restart();
         }
     }
 
@@ -304,7 +305,8 @@ public slots:
         if (m_sprite->m_frameRate != arg) {
             m_sprite->setFrameRate(arg);
             emit frameRateChanged(arg);
-            restart();
+            if (m_running)
+                restart();
         }
     }
 
@@ -313,7 +315,8 @@ public slots:
         if (m_sprite->m_frameDuration != arg) {
             m_sprite->setFrameDuration(arg);
             emit frameDurationChanged(arg);
-            restart();
+            if (m_running)
+                restart();
         }
     }
 
index 9176362..0429867 100644 (file)
@@ -11,4 +11,3 @@ TESTDATA = data/*
 CONFIG += parallel_test
 
 QT += core-private gui-private qml-private quick-private network testlib
-CONFIG += insignificant_test