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.

Task-number: QTBUG-30108

Change-Id: Ib9b2c5a0dea52762109e0b25f1068dd7c88e15ba
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
bb10
Jan Arve Saether 2013-03-12 11:24:37 +01:00 committed by The Qt Project
parent f75b7e78a3
commit 75614792fa
2 changed files with 26 additions and 0 deletions

View File

@ -744,7 +744,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);
}
}

View File

@ -69,6 +69,7 @@ private slots:
void stateInFinishedSignal();
void resume();
void restart();
void setPaused();
protected slots:
void finishedSlot();
@ -681,6 +682,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"