Fix a crash when QMovie::speed is set to 0
Setting speed to 0 means the current frame will continue to be shown, the finished signal is not emitted, and state remains QMovie::Running. Task-number: QTBUG-65758 Change-Id: I681d902e3211c5899b21043e5177b7c73d5d3fb5 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
f7524d73e3
commit
a966991b3a
@ -470,6 +470,10 @@ bool QMoviePrivate::next()
|
||||
currentPixmap = QPixmap::fromImage( info.pixmap.toImage().scaled(scaledSize) );
|
||||
else
|
||||
currentPixmap = info.pixmap;
|
||||
|
||||
if (!speed)
|
||||
return true;
|
||||
|
||||
nextDelay = speedAdjustedDelay(info.delay);
|
||||
// Adjust delay according to the time it took to read the frame
|
||||
int processingTime = time.elapsed();
|
||||
@ -504,7 +508,7 @@ void QMoviePrivate::_q_loadNextFrame(bool starting)
|
||||
emit q->updated(frameRect);
|
||||
emit q->frameChanged(currentFrameNumber);
|
||||
|
||||
if (movieState == QMovie::Running)
|
||||
if (speed && movieState == QMovie::Running)
|
||||
nextImageTimer.start(nextDelay);
|
||||
} else {
|
||||
// Could not read another frame
|
||||
@ -926,6 +930,8 @@ void QMovie::setPaused(bool paused)
|
||||
void QMovie::setSpeed(int percentSpeed)
|
||||
{
|
||||
Q_D(QMovie);
|
||||
if (!d->speed && d->movieState == Running)
|
||||
d->nextImageTimer.start(nextFrameDelay());
|
||||
d->speed = percentSpeed;
|
||||
}
|
||||
|
||||
|
@ -170,6 +170,16 @@ void tst_QMovie::playMovie()
|
||||
QCOMPARE(movie.state(), QMovie::NotRunning);
|
||||
QCOMPARE(movie.frameCount(), frameCount);
|
||||
#endif
|
||||
|
||||
movie.stop();
|
||||
QSignalSpy finishedSpy(&movie, &QMovie::finished);
|
||||
movie.setSpeed(0);
|
||||
movie.start();
|
||||
QCOMPARE(movie.state(), QMovie::Running);
|
||||
QTestEventLoop::instance().enterLoop(2);
|
||||
QCOMPARE(finishedSpy.count(), 0);
|
||||
QCOMPARE(movie.state(), QMovie::Running);
|
||||
QCOMPARE(movie.currentFrameNumber(), 0);
|
||||
}
|
||||
|
||||
void tst_QMovie::jumpToFrame_data()
|
||||
|
Loading…
Reference in New Issue
Block a user