summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2010-12-17 11:46:44 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2010-12-22 13:47:40 (GMT)
commitce432e1799111cbed492e46bb62d8dfb40585a10 (patch)
tree0175c56ec0fcd84a07e892b8deb6b52948493f48
parenta562fd2d201e3b618ed99a316275f20385cc5c25 (diff)
downloadQt-ce432e1799111cbed492e46bb62d8dfb40585a10.zip
Qt-ce432e1799111cbed492e46bb62d8dfb40585a10.tar.gz
Qt-ce432e1799111cbed492e46bb62d8dfb40585a10.tar.bz2
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
-rw-r--r--src/gui/image/qmovie.cpp6
-rw-r--r--tests/auto/qmovie/animations/corrupt.gifbin0 -> 847 bytes
-rw-r--r--tests/auto/qmovie/qmovie.pro1
-rw-r--r--tests/auto/qmovie/resources.qrc5
-rw-r--r--tests/auto/qmovie/tst_qmovie.cpp13
5 files changed, 24 insertions, 1 deletions
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
--- /dev/null
+++ b/tests/auto/qmovie/animations/corrupt.gif
Binary files 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 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>animations/corrupt.gif</file>
+</qresource>
+</RCC>
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"