diff options
3 files changed, 60 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicklistview/data/AnimatedButton.qml b/tests/auto/quick/qquicklistview/data/AnimatedButton.qml new file mode 100644 index 0000000000..19cd580cf5 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/AnimatedButton.qml @@ -0,0 +1,10 @@ +import QtQuick 2.12 + +/* + \qmltype AnimatedButton +*/ +Rectangle { + width: 100 + height: 20 + Behavior on color { ColorAnimation { duration : 300 } } +} diff --git a/tests/auto/quick/qquicklistview/data/animatedDelegate.qml b/tests/auto/quick/qquicklistview/data/animatedDelegate.qml new file mode 100644 index 0000000000..46913d87d7 --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/animatedDelegate.qml @@ -0,0 +1,35 @@ +import QtQuick 2.12 + +Item { + width: 640 + height: 480 + + property var moreModel: [myDataModelContainer.createObject(null)] + property Component myDataModelContainer: Component { + QtObject {} + } + + function refreshModel() { + //copy contents of moreModel + var list = moreModel.slice() + + moreModel = [myDataModelContainer.createObject(null), myDataModelContainer.createObject(null)] + + for (var i = 0; i < list.length; i++) { + //console.log("trying to destroy ="+list[i]) + list[i].destroy() + } + } + + ListView { + id: listView + objectName: "listView" + anchors.fill: parent + model: moreModel + focus: true + + delegate: AnimatedButton { + color: ListView.isCurrentItem ? "red" : "black" + } + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index 2af6b084fb..a7aefbe432 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -298,6 +298,7 @@ private slots: void requiredObjectListModel(); void clickHeaderAndFooterWhenClip(); + void animatedDelegate(); private: template <class T> void items(const QUrl &source); @@ -10094,6 +10095,20 @@ void tst_QQuickListView::clickHeaderAndFooterWhenClip() // QTBUG-85302 QVERIFY(root->property("footerPressed").toBool()); } +void tst_QQuickListView::animatedDelegate() +{ + // QTBUG-86567: Should not crash + QScopedPointer<QQuickView> window(createView()); + window->setSource(testFileUrl("animatedDelegate.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + for (int i = 0; i < 100; ++i) { + QMetaObject::invokeMethod(window->rootObject(), "refreshModel"); + QTest::qWait(10); + } +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" |