diff options
-rw-r--r-- | src/quick/items/qquickanimatedimage.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qmltest/animatedimage/tst_animatedimage.qml | 43 |
2 files changed, 44 insertions, 1 deletions
diff --git a/src/quick/items/qquickanimatedimage.cpp b/src/quick/items/qquickanimatedimage.cpp index adf460886a..a30d71dd1e 100644 --- a/src/quick/items/qquickanimatedimage.cpp +++ b/src/quick/items/qquickanimatedimage.cpp @@ -370,7 +370,7 @@ void QQuickAnimatedImage::movieRequestFinished() } #endif - if (!d->_movie->isValid()) { + if (!d->_movie || !d->_movie->isValid()) { qmlWarning(this) << "Error Reading Animated Image File " << d->url.toString(); delete d->_movie; d->_movie = 0; diff --git a/tests/auto/qmltest/animatedimage/tst_animatedimage.qml b/tests/auto/qmltest/animatedimage/tst_animatedimage.qml index 6ddd0e3024..c7e0aa2711 100644 --- a/tests/auto/qmltest/animatedimage/tst_animatedimage.qml +++ b/tests/auto/qmltest/animatedimage/tst_animatedimage.qml @@ -114,6 +114,44 @@ Item { fillMode: AnimatedImage.TileHorizontally } + Loader { + id: raceConditionLoader + active: false + anchors.fill: parent + + sourceComponent: ListView { + anchors.fill: parent + model: 5000 + delegate: Item { + height: 10 + width: parent.width + Text { + anchors.fill: parent + text: index + } + AnimatedImage { + anchors.fill: parent + source: "http://127.0.0.1/some-image-url.gif" + Component.onCompleted: source = ""; + } + } + + function scrollToNext() { + currentIndex = currentIndex + 30 < model ? currentIndex + 30 : model; + positionViewAtIndex(currentIndex, ListView.Beginning); + if (currentIndex >= model) + raceConditionLoader.active = false; + } + + property Timer timer: Timer { + interval: 10 + repeat: true + onTriggered: parent.scrollToNext() + Component.onCompleted: start() + } + } + } + TestCase { name: "AnimatedImage" @@ -216,5 +254,10 @@ Item { compare(tileModes3.fillMode, AnimatedImage.TileHorizontally) } + function test_crashRaceCondition_replyFinished() { + raceConditionLoader.active = true; + tryCompare(raceConditionLoader, "active", false); + } + } } |