aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2012-08-23 14:20:47 +1000
committerQt by Nokia <qt-info@nokia.com>2012-08-24 02:52:30 +0200
commit19e14d8e2aceb449d3788313165bd371be714a24 (patch)
tree665d7bbe27645d254cf775c7fb257dfcae0c9313 /tests
parent0853343c33e394f35c31c161b019b2aed17f9256 (diff)
Fix assert when a VisualDataModels context has been invalidated.
Verify the context is valid before attempting to access its engine. The context should normally be valid but there is a small window between a delegate item being released and the DeferredDelete event being processed when it is not. Task-number: QTBUG-26949 Change-Id: I79f3affaed8904cbe0974476010b68305666cd29 Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
index e55c537529..fce746b361 100644
--- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
+++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
@@ -437,6 +437,7 @@ private slots:
void asynchronousMove();
void asynchronousMove_data();
void asynchronousCancel();
+ void invalidContext();
private:
template <int N> void groups_verify(
@@ -4206,6 +4207,35 @@ void tst_qquickvisualdatamodel::asynchronousCancel()
QCOMPARE(controller.incubatingObjectCount(), 0);
}
+void tst_qquickvisualdatamodel::invalidContext()
+{
+ QQmlEngine engine;
+ QaimModel model;
+ for (int i = 0; i < 8; i++)
+ model.addItem("Original item" + QString::number(i), "");
+
+ engine.rootContext()->setContextProperty("myModel", &model);
+
+ QScopedPointer<QQmlContext> context(new QQmlContext(engine.rootContext()));
+
+ QQmlComponent c(&engine, testFileUrl("visualdatamodel.qml"));
+
+
+ QQuickVisualDataModel *visualModel = qobject_cast<QQuickVisualDataModel*>(c.create(context.data()));
+ QVERIFY(visualModel);
+
+ QQuickItem *item = visualModel->item(4, false);
+ QVERIFY(item);
+ visualModel->release(item);
+
+ delete context.take();
+
+ model.insertItem(4, "new item", "");
+
+ item = visualModel->item(4, false);
+ QVERIFY(!item);
+}
+
QTEST_MAIN(tst_qquickvisualdatamodel)
#include "tst_qquickvisualdatamodel.moc"