diff options
author | Charles Yin <charles.yin@nokia.com> | 2012-01-20 15:41:16 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-03 02:08:05 +0100 |
commit | ff8f1ac8caa86006a887d9104886aadd23f8750c (patch) | |
tree | 0b88914e086690d7f46e314a9bc4e7aca3c3ab67 /tests/auto/declarative | |
parent | 348b51327fe72fc8ea4292a3b5cb4df178c1d234 (diff) |
Fix crash bug related to QDeclarativeListModel
If QDeclarativeListModel is deleted, all references to this object in
QDeclarativeListModelWorkerAgent and WorkerScript objects should be removed
and additional checking is needed when process the pending sync() events.
Change-Id: I12b1f06699cc908e684af0886cf06d811c3fceb4
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Reviewed-by: Glenn Watson <glenn.watson@nokia.com>
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r-- | tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index ff0d3facc4..4eb723bf8e 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -1481,6 +1481,28 @@ void tst_qdeclarativelistmodel::worker_remove_element() delete item; qApp->processEvents(); + + { + //don't crash if model was deleted earlier + QDeclarativeListModel* model = new QDeclarativeListModel; + model->setDynamicRoles(dynamicRoles); + QDeclarativeEngine eng; + QDeclarativeComponent component(&eng, testFileUrl("workerremoveelement.qml")); + QQuickItem *item = createWorkerTest(&eng, &component, model); + QVERIFY(item != 0); + + QVERIFY(QMetaObject::invokeMethod(item, "addItem")); + + QVERIFY(model->count() == 1); + + QVERIFY(QMetaObject::invokeMethod(item, "removeItemViaWorker")); + QVERIFY(QMetaObject::invokeMethod(item, "doSync")); + delete model; + qApp->processEvents(); //must not crash here + waitForWorker(item); + + delete item; + } } void tst_qdeclarativelistmodel::worker_remove_list_data() |