aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-06-15 15:51:01 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2020-06-15 17:52:16 +0200
commitab03621516630991c7cc0fea3be79879efed23a8 (patch)
treec063478414f43d7f98f8c9f7038daa532bb8b646 /tests/auto/quick
parent828cdcabf84734a753e3ba8b8e4b089a6e155415 (diff)
Cull removed items from QQuickItemView
Amends a20132c326f6d2c5fec848efb98dd86afb320e2a, which fixed a crash, but also prevented the item from being culled. This is fixed by narrowing the scope of the condition to affect only the caching related part. Fixes: QTBUG-84604 Pick-to: 5.15 Change-Id: I9b8a1a148d6538a18280475d89b87a4049ff3465 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r--tests/auto/quick/qquicklistview/data/objectModelCulling.qml35
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp25
2 files changed, 60 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/objectModelCulling.qml b/tests/auto/quick/qquicklistview/data/objectModelCulling.qml
new file mode 100644
index 0000000000..c0a70ec485
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/objectModelCulling.qml
@@ -0,0 +1,35 @@
+import QtQuick 2.12
+
+import QtQml.Models 2.12
+
+Item {
+
+ ObjectModel {
+ id: model1
+ objectName: "model1"
+
+ Rectangle {
+ color: "red"
+ objectName: "redRect"
+ height: 30; width: 80;
+ }
+ }
+
+ ObjectModel {
+ id: model2
+ objectName: "model2"
+
+ Rectangle {
+ color: "green"
+ height: 30; width: 80;
+ x:10
+ }
+ }
+
+ ListView {
+ id: listView
+ objectName: "lv"
+
+ anchors.fill: parent
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index 46e59d229e..56c3f370d2 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -294,6 +294,7 @@ private slots:
void reuse_checkThatItemsAreReused();
void moveObjectModelItemToAnotherObjectModel();
void changeModelAndDestroyTheOldOne();
+ void objectModelCulling();
void requiredObjectListModel();
@@ -9989,6 +9990,30 @@ void tst_QQuickListView::changeModelAndDestroyTheOldOne() // QTBUG-80203
// no crash
}
+void tst_QQuickListView::objectModelCulling()
+{
+ QScopedPointer<QQuickView> window(createView());
+ window->setSource(testFileUrl("objectModelCulling.qml"));
+ window->resize(640, 480);
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+ QObject *root = window->rootObject();
+ QVERIFY(root);
+ auto listView = root->findChild<QQuickListView *>("lv");
+ QVERIFY(listView);
+ auto model1 = root->findChild<QObject *>("model1");
+ QVERIFY(model1);
+ auto model2 = root->findChild<QObject *>("model2");
+ QVERIFY(model2);
+ auto redRect = root->findChild<QQuickItem *>("redRect");
+ QVERIFY(redRect);
+ auto redRectPriv = QQuickItemPrivate::get(redRect);
+ listView->setModel(QVariant::fromValue(model1));
+ QVERIFY(!redRectPriv->culled);
+ listView->setModel(QVariant::fromValue(model2));
+ QTRY_VERIFY(redRectPriv->culled);
+}
+
class DataObject : public QObject
{
Q_OBJECT