From ce432e1799111cbed492e46bb62d8dfb40585a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 17 Dec 2010 12:46:44 +0100 Subject: Prevented infinite loop in QMoviePrivate::next(). If we're unable to read the first frame, we shouldn't return an end marker, as that will cause QMoviePrivate::next() to recurse indefinitely when the playCounter is set to -1 (infinite). Reviewed-by: Olivier Goffart --- src/gui/image/qmovie.cpp | 6 +++++- tests/auto/qmovie/animations/corrupt.gif | Bin 0 -> 847 bytes tests/auto/qmovie/qmovie.pro | 1 + tests/auto/qmovie/resources.qrc | 5 +++++ tests/auto/qmovie/tst_qmovie.cpp | 13 +++++++++++++ 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/auto/qmovie/animations/corrupt.gif create mode 100644 tests/auto/qmovie/resources.qrc diff --git a/src/gui/image/qmovie.cpp b/src/gui/image/qmovie.cpp index 911a2b5..eb139fa 100644 --- a/src/gui/image/qmovie.cpp +++ b/src/gui/image/qmovie.cpp @@ -381,10 +381,14 @@ QFrameInfo QMoviePrivate::infoForFrame(int frameNumber) QPixmap aPixmap = QPixmap::fromImage(anImage); int aDelay = reader->nextImageDelay(); return QFrameInfo(aPixmap, aDelay); - } else { + } else if (frameNumber != 0) { // We've read all frames now. Return an end marker haveReadAll = true; return QFrameInfo::endMarker(); + } else { + // No readable frames + haveReadAll = true; + return QFrameInfo(); } } diff --git a/tests/auto/qmovie/animations/corrupt.gif b/tests/auto/qmovie/animations/corrupt.gif new file mode 100644 index 0000000..c1545eb Binary files /dev/null and b/tests/auto/qmovie/animations/corrupt.gif differ diff --git a/tests/auto/qmovie/qmovie.pro b/tests/auto/qmovie/qmovie.pro index 6973955..855eb9e 100644 --- a/tests/auto/qmovie/qmovie.pro +++ b/tests/auto/qmovie/qmovie.pro @@ -12,6 +12,7 @@ wince*: { DEPLOYMENT += addFiles } +RESOURCES += resources.qrc symbian: { addFiles.files = animations\\* diff --git a/tests/auto/qmovie/resources.qrc b/tests/auto/qmovie/resources.qrc new file mode 100644 index 0000000..ce459a0 --- /dev/null +++ b/tests/auto/qmovie/resources.qrc @@ -0,0 +1,5 @@ + + + animations/corrupt.gif + + diff --git a/tests/auto/qmovie/tst_qmovie.cpp b/tests/auto/qmovie/tst_qmovie.cpp index 80a551b..d43d4cb 100644 --- a/tests/auto/qmovie/tst_qmovie.cpp +++ b/tests/auto/qmovie/tst_qmovie.cpp @@ -72,6 +72,7 @@ private slots: void jumpToFrame_data(); void jumpToFrame(); void changeMovieFile(); + void infiniteLoop(); }; // Testing get/set functions @@ -208,5 +209,17 @@ void tst_QMovie::changeMovieFile() QVERIFY(movie.currentFrameNumber() == -1); } +void tst_QMovie::infiniteLoop() +{ + QLabel label; + label.show(); + QMovie *movie = new QMovie(QLatin1String(":animations/corrupt.gif"), QByteArray(), &label); + label.setMovie(movie); + movie->start(); + + QTestEventLoop::instance().enterLoop(1); + QTestEventLoop::instance().timeout(); +} + QTEST_MAIN(tst_QMovie) #include "tst_qmovie.moc" -- cgit v0.12