diff options
Diffstat (limited to 'tests/auto/quick/qquickrepeater')
-rw-r--r-- | tests/auto/quick/qquickrepeater/data/dynamicmodelcrash.qml | 20 | ||||
-rw-r--r-- | tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp | 15 |
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickrepeater/data/dynamicmodelcrash.qml b/tests/auto/quick/qquickrepeater/data/dynamicmodelcrash.qml new file mode 100644 index 0000000000..0280df0620 --- /dev/null +++ b/tests/auto/quick/qquickrepeater/data/dynamicmodelcrash.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Item { + ListModel { + id: lm; + } + + Component.onCompleted: { + lm.append({ subModel: [ {d:0} ] }); + rep.model = lm.get(0).subModel; + rep.model; + lm.remove(0); + rep.model; + } + + Repeater { + objectName: "rep" + id: rep + } +} diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp index 1b07a6e9f8..d9cbed093a 100644 --- a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp +++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp @@ -77,6 +77,7 @@ private slots: void properties(); void asynchronous(); void initParent(); + void dynamicModelCrash(); }; class TestObject : public QObject @@ -639,6 +640,20 @@ void tst_QQuickRepeater::initParent() QCOMPARE(qvariant_cast<QQuickItem*>(rootObject->property("parentItem")), rootObject); } +void tst_QQuickRepeater::dynamicModelCrash() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("dynamicmodelcrash.qml")); + + // Don't crash + QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create()); + QVERIFY(rootObject); + + QQuickRepeater *repeater = findItem<QQuickRepeater>(rootObject, "rep"); + QVERIFY(repeater); + QVERIFY(qvariant_cast<QObject *>(repeater->model()) == 0); +} + QTEST_MAIN(tst_QQuickRepeater) #include "tst_qquickrepeater.moc" |