summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@digia.com>2013-03-12 10:24:37 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-20 08:16:57 (GMT)
commit1d2234498cde6821014fcec7f2b321ad76724cce (patch)
treedbd0ae6561786146d26e5cec45a89493bd38fc24
parent32a66514c6a907604c1efced5ba0c885ea7c7355 (diff)
downloadQt-1d2234498cde6821014fcec7f2b321ad76724cce.zip
Qt-1d2234498cde6821014fcec7f2b321ad76724cce.tar.gz
Qt-1d2234498cde6821014fcec7f2b321ad76724cce.tar.bz2
Fixed bug in QTimeLine::setPaused(false)
The problem was that the elapsed timer was not restarted, causing the currentTime() not being adjusted for the time it was paused. (cherry-picked from Qt 5: 75614792fa2370b6b0402117bf) Task-number: QTBUG-30108 Change-Id: I9718aa408075623514717328321c34e7ab3af436 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
-rw-r--r--src/corelib/tools/qtimeline.cpp3
-rw-r--r--tests/auto/qtimeline/tst_qtimeline.cpp23
2 files changed, 26 insertions, 0 deletions
diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp
index 1cfbe43..7d4dd90 100644
--- a/src/corelib/tools/qtimeline.cpp
+++ b/src/corelib/tools/qtimeline.cpp
@@ -748,7 +748,10 @@ void QTimeLine::setPaused(bool paused)
d->timerId = 0;
d->setState(Paused);
} else if (!paused && d->state == Paused) {
+ // Same as resume()
d->timerId = startTimer(d->updateInterval);
+ d->startTime = d->currentTime;
+ d->timer.start();
d->setState(Running);
}
}
diff --git a/tests/auto/qtimeline/tst_qtimeline.cpp b/tests/auto/qtimeline/tst_qtimeline.cpp
index ab83e9d..21c548e 100644
--- a/tests/auto/qtimeline/tst_qtimeline.cpp
+++ b/tests/auto/qtimeline/tst_qtimeline.cpp
@@ -82,6 +82,7 @@ private slots:
void stateInFinishedSignal();
void resume();
void restart();
+ void setPaused();
protected slots:
void finishedSlot();
@@ -725,6 +726,28 @@ void tst_QTimeLine::restart()
QCOMPARE(timeLine.currentTime(), 0);
}
+void tst_QTimeLine::setPaused()
+{
+ QTimeLine timeLine(1000);
+ {
+ QCOMPARE(timeLine.currentTime(), 0);
+ timeLine.start();
+ QTest::qWait(250);
+ timeLine.setPaused(true);
+ int oldCurrentTime = timeLine.currentTime();
+ QVERIFY(oldCurrentTime > 0);
+ QVERIFY(oldCurrentTime < 1000);
+ QTest::qWait(1000);
+ timeLine.setPaused(false);
+ QTest::qWait(250);
+ int currentTime = timeLine.currentTime();
+ QVERIFY(currentTime > 0);
+ QVERIFY(currentTime > oldCurrentTime);
+ QVERIFY(currentTime < 1000);
+ timeLine.stop();
+ }
+}
+
QTEST_MAIN(tst_QTimeLine)
#include "tst_qtimeline.moc"