From 30e3a39ca2e5e1204cc123dce2f2921d8fda620d Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 4 Aug 2009 15:03:15 +0200 Subject: QParallelAnimationGroup pause resume fixed If you resumed a parallel animation group, it would always restart (ie. stop and start) the animation which would reset its current time to 0 and trigger flickering. autotest included. Task-Number: 259102 --- src/corelib/animation/qparallelanimationgroup.cpp | 3 +- .../tst_qparallelanimationgroup.cpp | 33 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/corelib/animation/qparallelanimationgroup.cpp b/src/corelib/animation/qparallelanimationgroup.cpp index 5e4b0d2..8aa04a4 100644 --- a/src/corelib/animation/qparallelanimationgroup.cpp +++ b/src/corelib/animation/qparallelanimationgroup.cpp @@ -214,7 +214,8 @@ void QParallelAnimationGroup::updateState(QAbstractAnimation::State oldState, d->connectUncontrolledAnimations(); for (int i = 0; i < d->animations.size(); ++i) { QAbstractAnimation *animation = d->animations.at(i); - animation->stop(); + if (oldState == Stopped) + animation->stop(); animation->setDirection(d->direction); animation->start(); } diff --git a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index d7d6b88..16c58b0 100644 --- a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -74,6 +74,7 @@ private slots: void loopCount_data(); void loopCount(); void autoAdd(); + void pauseResume(); }; tst_QParallelAnimationGroup::tst_QParallelAnimationGroup() @@ -828,5 +829,37 @@ void tst_QParallelAnimationGroup::autoAdd() QCOMPARE(group.duration(), 0); } +void tst_QParallelAnimationGroup::pauseResume() +{ + QParallelAnimationGroup group; + TestAnimation2 *anim = new TestAnimation2(250, &group); // 0, duration = 250; + QSignalSpy spy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); + QCOMPARE(group.duration(), 250); + group.start(); + QTest::qWait(100); + QCOMPARE(group.state(), QAnimationGroup::Running); + QCOMPARE(anim->state(), QAnimationGroup::Running); + QCOMPARE(spy.count(), 1); + spy.clear(); + const int currentTime = group.currentTime(); + QCOMPARE(anim->currentTime(), currentTime); + + group.pause(); + QCOMPARE(group.state(), QAnimationGroup::Paused); + QCOMPARE(group.currentTime(), currentTime); + QCOMPARE(anim->state(), QAnimationGroup::Paused); + QCOMPARE(anim->currentTime(), currentTime); + QCOMPARE(spy.count(), 1); + spy.clear(); + + group.resume(); + QCOMPARE(group.state(), QAnimationGroup::Running); + QCOMPARE(group.currentTime(), currentTime); + QCOMPARE(anim->state(), QAnimationGroup::Running); + QCOMPARE(anim->currentTime(), currentTime); + QCOMPARE(spy.count(), 1); +} + + QTEST_MAIN(tst_QParallelAnimationGroup) #include "tst_qparallelanimationgroup.moc" -- cgit v0.12