diff options
author | Joni Poikelin <joni.poikelin@qt.io> | 2020-09-03 14:22:26 +0300 |
---|---|---|
committer | Joni Poikelin <joni.poikelin@qt.io> | 2020-09-23 08:26:58 +0300 |
commit | 149c1dd07b54ee0c027d94a49d52160dc4f4e2ac (patch) | |
tree | 6ce6e679b87ebf5b29f32d6fc9a581b92b8cae48 /tests/auto/quick/qquickgridview | |
parent | feecc5a3206e408023ef0d2cb38d3847c3319dee (diff) |
Prevent crash when destroying asynchronous Loader
Fixes: QTBUG-86255
Pick-to: 5.15
Change-Id: I30488b64d910a1409a43e2e98ee7ab084aec33d2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickgridview')
-rw-r--r-- | tests/auto/quick/qquickgridview/data/qtbug86255.qml | 55 | ||||
-rw-r--r-- | tests/auto/quick/qquickgridview/tst_qquickgridview.cpp | 13 |
2 files changed, 68 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickgridview/data/qtbug86255.qml b/tests/auto/quick/qquickgridview/data/qtbug86255.qml new file mode 100644 index 0000000000..20688b1967 --- /dev/null +++ b/tests/auto/quick/qquickgridview/data/qtbug86255.qml @@ -0,0 +1,55 @@ +import QtQuick 2.15 + +Item { + width: 240 + height: 320 + + GridView { + id: grid + objectName: "view" + anchors.fill: parent + cellWidth: 64 + cellHeight: 64 + model: ListModel { + id: listModel + + Component.onCompleted: reload() + + function reload() { + clear(); + for (let i = 0; i < 1000; i++) { + let magic = Math.random(); + append( { magic } ); + } + } + } + clip: true + delegate: Item { + id: d + property string val: magic + Loader { + property alias value: d.val + asynchronous: true + sourceComponent: cmp + } + } + } + + Timer { + running: true + interval: 1000 + onTriggered: listModel.reload() + } + Timer { + running: true + interval: 500 + onTriggered: grid.flick(0, -4000) + } + + Component { + id: cmp + Text { + text: value + } + } +} diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp index 81b76cec25..323513400a 100644 --- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp +++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp @@ -213,6 +213,7 @@ private slots: void QTBUG_45640(); void QTBUG_49218(); void QTBUG_48870_fastModelUpdates(); + void QTBUG_86255(); void keyNavigationEnabled(); void releaseItems(); @@ -6795,6 +6796,18 @@ void tst_QQuickGridView::QTBUG_48870_fastModelUpdates() } } +void tst_QQuickGridView::QTBUG_86255() +{ + QScopedPointer<QQuickView> window(createView()); + window->setSource(testFileUrl("qtbug86255.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + QQuickGridView *view = findItem<QQuickGridView>(window->rootObject(), "view"); + QVERIFY(view != nullptr); + QTRY_COMPARE(view->isFlicking(), true); + QTRY_COMPARE(view->isFlicking(), false); +} + void tst_QQuickGridView::releaseItems() { QScopedPointer<QQuickView> view(createView()); |