summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/animation/qabstractanimation.cpp4
-rw-r--r--tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp33
2 files changed, 37 insertions, 0 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 71eb9c9f9c..a7d428384a 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -286,6 +286,10 @@ void QUnifiedTimer::setTimingInterval(int interval)
void QUnifiedTimer::startAnimations()
{
startAnimationPending = false;
+ //force timer to update, which prevents large deltas for our newly added animations
+ if (!animations.isEmpty())
+ updateAnimationsTime(-1);
+
//we transfer the waiting animations into the "really running" state
animations += animationsToStart;
animationsToStart.clear();
diff --git a/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp b/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp
index 083324bdd8..28118aa203 100644
--- a/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp
+++ b/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp
@@ -60,6 +60,7 @@ private slots:
void totalDuration();
void avoidJumpAtStart();
void avoidJumpAtStartWithStop();
+ void avoidJumpAtStartWithRunning();
};
class TestableQAbstractAnimation : public QAbstractAnimation
@@ -180,6 +181,9 @@ void tst_QAbstractAnimation::avoidJumpAtStartWithStop()
TestableQAbstractAnimation anim2;
anim2.setDuration(1000);
+ TestableQAbstractAnimation anim3;
+ anim3.setDuration(1000);
+
anim.start();
QTest::qWait(300);
anim.stop();
@@ -190,10 +194,39 @@ void tst_QAbstractAnimation::avoidJumpAtStartWithStop()
*/
anim2.start();
QTest::qSleep(300);
+ anim3.start();
+ QCoreApplication::processEvents();
+ QVERIFY(anim2.currentTime() < 50);
+ QVERIFY(anim3.currentTime() < 50);
+}
+
+void tst_QAbstractAnimation::avoidJumpAtStartWithRunning()
+{
+ TestableQAbstractAnimation anim;
+ anim.setDuration(2000);
+
+ TestableQAbstractAnimation anim2;
+ anim2.setDuration(1000);
+
+ TestableQAbstractAnimation anim3;
+ anim3.setDuration(1000);
+
+ anim.start();
+ QTest::qWait(300); //make sure timer has started
+
+ /*
+ same test as avoidJumpAtStart, but with an
+ existing running animation
+ */
+ anim2.start();
+ QTest::qSleep(300); //force large delta for next tick
+ anim3.start();
QCoreApplication::processEvents();
QVERIFY(anim2.currentTime() < 50);
+ QVERIFY(anim3.currentTime() < 50);
}
+
QTEST_MAIN(tst_QAbstractAnimation)
#include "tst_qabstractanimation.moc"