diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-08-02 15:19:06 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-05 04:56:52 +0200 |
commit | bbe72dadd3ab73a2a3a7dabfb9db3e99b36a272a (patch) | |
tree | 4df5c242fd4fbb23056c30e14717a01beed91eee /tests | |
parent | aa54e27adeff3c7e6f59e2d68e9f006e60e542dc (diff) |
Don't cache model data in VisualDataModel.
VisualDataModel doesn't have any way to monitor the lifetime of objects
cached other than relying on the source model to emit a changed signal.
If the model doesn't do this or a pointer property is referenced after
an item has been removed from the model then cache can return a stale
pointer. This can be avoided by querying the model directly whenever
a property is accessed.
Task-number: QTBUG-18036
Change-Id: I7688174c2337cb5c0f77eb7d31a01f4aa958071b
Reviewed-on: http://codereview.qt.nokia.com/2647
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'tests')
10 files changed, 11 insertions, 7 deletions
diff --git a/tests/auto/declarative/qsggridview/data/gridview1.qml b/tests/auto/declarative/qsggridview/data/gridview1.qml index 0f148ed387..e6a3923532 100644 --- a/tests/auto/declarative/qsggridview/data/gridview1.qml +++ b/tests/auto/declarative/qsggridview/data/gridview1.qml @@ -20,6 +20,7 @@ Rectangle { width: 80 height: 60 border.color: "blue" + property string name: model.name Text { text: index } diff --git a/tests/auto/declarative/qsggridview/tst_qsggridview.cpp b/tests/auto/declarative/qsggridview/tst_qsggridview.cpp index 11d90eca6e..c478f0dab3 100644 --- a/tests/auto/declarative/qsggridview/tst_qsggridview.cpp +++ b/tests/auto/declarative/qsggridview/tst_qsggridview.cpp @@ -1344,7 +1344,7 @@ void tst_QSGGridView::modelChanges() QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel"); QTRY_VERIFY(alternateModel); - QVariant modelVariant = QVariant::fromValue(alternateModel); + QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel); QSignalSpy modelSpy(gridView, SIGNAL(modelChanged())); gridView->setModel(modelVariant); diff --git a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp index 6f19692ad0..59847d37f5 100644 --- a/tests/auto/declarative/qsglistview/tst_qsglistview.cpp +++ b/tests/auto/declarative/qsglistview/tst_qsglistview.cpp @@ -2008,7 +2008,7 @@ void tst_QSGListView::modelChanges() QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel"); QTRY_VERIFY(alternateModel); - QVariant modelVariant = QVariant::fromValue(alternateModel); + QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel); QSignalSpy modelSpy(listView, SIGNAL(modelChanged())); listView->setModel(modelVariant); diff --git a/tests/auto/declarative/qsgpathview/tst_qsgpathview.cpp b/tests/auto/declarative/qsgpathview/tst_qsgpathview.cpp index 00202f7436..96a591f511 100644 --- a/tests/auto/declarative/qsgpathview/tst_qsgpathview.cpp +++ b/tests/auto/declarative/qsgpathview/tst_qsgpathview.cpp @@ -835,7 +835,7 @@ void tst_QSGPathView::modelChanges() QDeclarativeListModel *alternateModel = canvas->rootObject()->findChild<QDeclarativeListModel*>("alternateModel"); QVERIFY(alternateModel); - QVariant modelVariant = QVariant::fromValue(alternateModel); + QVariant modelVariant = QVariant::fromValue<QObject *>(alternateModel); QSignalSpy modelSpy(pathView, SIGNAL(modelChanged())); pathView->setModel(modelVariant); diff --git a/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties.qml b/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties.qml index 6d86cdea2e..73b766f1af 100644 --- a/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties.qml +++ b/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties.qml @@ -6,6 +6,8 @@ ListView { model: myModel delegate: Item { objectName: "delegate" + width: 100 + height: 2 property variant test1: name property variant test2: model.name property variant test3: modelData diff --git a/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties2.qml b/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties2.qml index 6a92431cdf..ea5c240b29 100644 --- a/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties2.qml +++ b/tests/auto/declarative/qsgvisualdatamodel/data/modelproperties2.qml @@ -15,5 +15,7 @@ ListView { property variant test7: index property variant test8: model.index property variant test9: model.modelData.display + width: 100 + height: 2 } } diff --git a/tests/auto/declarative/qsgvisualdatamodel/data/objectlist.qml b/tests/auto/declarative/qsgvisualdatamodel/data/objectlist.qml index 9086e5ab57..b3952a8a4d 100644 --- a/tests/auto/declarative/qsgvisualdatamodel/data/objectlist.qml +++ b/tests/auto/declarative/qsgvisualdatamodel/data/objectlist.qml @@ -10,7 +10,7 @@ ListView { height: 25 width: 100 color: model.modelData.color - Text { objectName: "name"; text: name } + Text { objectName: "name"; text: name; function getText() { return name } } Text { objectName: "section"; text: parent.ListView.section } } } diff --git a/tests/auto/declarative/qsgvisualdatamodel/data/singlerole1.qml b/tests/auto/declarative/qsgvisualdatamodel/data/singlerole1.qml index d5b0fcf09b..c471893e1d 100644 --- a/tests/auto/declarative/qsgvisualdatamodel/data/singlerole1.qml +++ b/tests/auto/declarative/qsgvisualdatamodel/data/singlerole1.qml @@ -5,6 +5,6 @@ ListView { height: 100 model: myModel delegate: Component { - Text { objectName: "name"; text: name } + Text { objectName: "name"; text: name; function getText() { return name; } } } } diff --git a/tests/auto/declarative/qsgvisualdatamodel/data/singlerole2.qml b/tests/auto/declarative/qsgvisualdatamodel/data/singlerole2.qml index c6d3413dfd..ab1798999d 100644 --- a/tests/auto/declarative/qsgvisualdatamodel/data/singlerole2.qml +++ b/tests/auto/declarative/qsgvisualdatamodel/data/singlerole2.qml @@ -5,6 +5,6 @@ ListView { height: 100 model: myModel delegate: Component { - Text { objectName: "name"; text: modelData } + Text { objectName: "name"; text: modelData; function getText() { return modelData } } } } diff --git a/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp b/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp index e56fcb062e..7470153933 100644 --- a/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp +++ b/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp @@ -460,7 +460,6 @@ void tst_qsgvisualdatamodel::modelProperties() QSGItem *delegate = findItem<QSGItem>(contentItem, "delegate", 1); QVERIFY(delegate); QCOMPARE(delegate->property("test1").toString(),QString("Item 2")); - QEXPECT_FAIL("", "QTBUG-13576", Continue); QCOMPARE(delegate->property("test2").toString(),QString("Item 2")); QVERIFY(qobject_cast<DataObject*>(delegate->property("test3").value<QObject*>()) != 0); QVERIFY(qobject_cast<DataObject*>(delegate->property("test4").value<QObject*>()) != 0); |