aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicklistview
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-01-20 01:00:12 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-01-20 09:37:57 +0100
commit67ac9dead884c7558896bdd97e4d3152100dc7ec (patch)
tree000ef894b1f7d649b293cd08c2d8235f72201f19 /tests/auto/quick/qquicklistview
parente5f7c5f2712957d0e1753c629e4cce86a0e6bdbc (diff)
parent953e04346773beb5d10c3758a12aae5c82646ae1 (diff)
Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts: src/quick/items/qquickitemview.cpp Change-Id: Ib9faebdbef5eebb80f4e6aeb5b15b5df7494b157
Diffstat (limited to 'tests/auto/quick/qquicklistview')
-rw-r--r--tests/auto/quick/qquicklistview/data/changeModelAndDestroyTheOldOne.qml34
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp16
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/changeModelAndDestroyTheOldOne.qml b/tests/auto/quick/qquicklistview/data/changeModelAndDestroyTheOldOne.qml
new file mode 100644
index 0000000000..6a33decde6
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/changeModelAndDestroyTheOldOne.qml
@@ -0,0 +1,34 @@
+import QtQuick 2.13
+import QtQml 2.13
+import QtQml.Models 2.13
+
+Rectangle {
+ width: 640
+ height: 480
+ property var model1: null
+ property var model2: null
+ Component {
+ id: m1
+ ObjectModel {
+ Rectangle { height: 30; width: 80; color: "red" }
+ Rectangle { height: 30; width: 80; color: "green" }
+ Rectangle { height: 30; width: 80; color: "blue" }
+ }
+ }
+ Component {
+ id: m2
+ ObjectModel {
+ Rectangle { height: 30; width: 80; color: "red" }
+ }
+ }
+ ListView {
+ anchors.fill: parent
+ Component.onCompleted: {
+ model1 = m1.createObject()
+ model = model1
+ model2 = m2.createObject()
+ model = model2
+ model1.destroy()
+ }
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index e527853148..9a8dfee9d2 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -289,6 +289,7 @@ private slots:
void reuse_reuseIsOffByDefault();
void reuse_checkThatItemsAreReused();
void moveObjectModelItemToAnotherObjectModel();
+ void changeModelAndDestroyTheOldOne();
private:
template <class T> void items(const QUrl &source);
@@ -9415,6 +9416,21 @@ void tst_QQuickListView::moveObjectModelItemToAnotherObjectModel()
QVERIFY(!QQuickItemPrivate::get(redRect)->culled);
}
+void tst_QQuickListView::changeModelAndDestroyTheOldOne() // QTBUG-80203
+{
+ QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("changeModelAndDestroyTheOldOne.qml"));
+ window->resize(640, 480);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ QQuickItem *root = window->rootObject();
+ QVERIFY(root);
+
+ QVERIFY(QQuickTest::qWaitForItemPolished(root));
+ // no crash
+}
+
QTEST_MAIN(tst_QQuickListView)
#include "tst_qquicklistview.moc"