diff options
author | Aleksei Ilin <a.ilin@outlook.com> | 2017-08-08 12:44:42 +0200 |
---|---|---|
committer | Aleksei Ilin <a.ilin@outlook.com> | 2017-08-10 20:08:18 +0000 |
commit | fc3ecd2522deb3f6d8d48b66dbd89402e1ab4b53 (patch) | |
tree | fb9b0cb0cbb659d7ce1d77f93c1b03f40fc557ba | |
parent | b04b7d340f39dfdde560b1303ea6a8c8ace8056e (diff) |
Fix crash in QQuickAnimatedImage
Check d->_movie pointer before dereferencing
Task-number: QTBUG-62380
Change-Id: I62314c7c0d4a7e41fa6f8c4629d16f30d6036156
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
-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); + } + } } |