aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickrepeater
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@live.com>2015-06-23 13:13:01 -0500
committerMichael Brasser <michael.brasser@live.com>2015-06-30 14:57:48 +0000
commit9d0e702b1f29c8120f2000e1558a7b040311d8c0 (patch)
tree33ed02784bfe5d29ffa84faafa128005b97991a6 /tests/auto/quick/qquickrepeater
parentf869d0e550f7fcc664c9280a09c0c75adf24669b (diff)
Prevent errors when removing items from Repeater that reference parent.
Use the same ordering as item views and release before unparenting. Change-Id: I0346342cfcaf9385d8385769795dd5ba35fc43aa Task-number: QTBUG-46828 Reviewed-by: Liang Qi <liang.qi@theqtcompany.com> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'tests/auto/quick/qquickrepeater')
-rw-r--r--tests/auto/quick/qquickrepeater/data/modelCleared.qml17
-rw-r--r--tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp21
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickrepeater/data/modelCleared.qml b/tests/auto/quick/qquickrepeater/data/modelCleared.qml
new file mode 100644
index 0000000000..1269e9bdf2
--- /dev/null
+++ b/tests/auto/quick/qquickrepeater/data/modelCleared.qml
@@ -0,0 +1,17 @@
+import QtQuick 2.0
+
+Row {
+ spacing: 2
+ height: 100
+
+ Repeater {
+ id: repeater
+ objectName: "repeater"
+ model: 10
+ Rectangle {
+ color: "green"
+ width: 10; height: 50
+ anchors.bottom: parent.bottom
+ }
+ }
+}
diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
index 3d0bb8f1ed..559f816a9b 100644
--- a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
+++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp
@@ -68,6 +68,7 @@ private slots:
void resetModel();
void modelChanged();
void modelReset();
+ void modelCleared();
void properties();
void asynchronous();
void initParent();
@@ -634,6 +635,26 @@ void tst_QQuickRepeater::modelReset()
QCOMPARE(addedSpy.count(), 0);
}
+// QTBUG-46828
+void tst_QQuickRepeater::modelCleared()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, testFileUrl("modelCleared.qml"));
+
+ QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
+ QVERIFY(rootObject);
+
+ QQuickRepeater *repeater = findItem<QQuickRepeater>(rootObject, "repeater");
+ QVERIFY(repeater);
+
+ // verify no error messages when the model is cleared and the items are destroyed
+ QQmlTestMessageHandler messageHandler;
+ repeater->setModel(0);
+ QVERIFY2(messageHandler.messages().isEmpty(), qPrintable(messageHandler.messageString()));
+
+ delete rootObject;
+}
+
void tst_QQuickRepeater::properties()
{
QQmlEngine engine;