QTimeLine: do not restart() an invalid QElapsedTimer

It's UB (as per docs). Creating a QTimeLine and calling
setCurrentTime() will end up calling restart() without having called
start() first. Moreover, the return value of restart() isn't used,
so that's useless work.

Pick-to: 6.8 6.5
Change-Id: I53c80838f60fae406a44ffe2cf578c6c79cc9df4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit a43453d9a2b12943cb4528a4249fce407a3318f4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Giuseppe D'Angelo 2025-03-14 10:20:39 +01:00 committed by Qt Cherry-pick Bot
parent 49f7778698
commit c376c79b91

View File

@ -538,7 +538,7 @@ void QTimeLine::setCurrentTime(int msec)
Q_D(QTimeLine);
d->startTime = 0;
d->currentLoopCount = 0;
d->timer.restart();
d->timer.start();
d->setCurrentTime(msec);
}