diff options
author | Andrew den Exter <[email protected]> | 2011-09-15 18:03:32 +1000 |
---|---|---|
committer | Qt by Nokia <[email protected]> | 2011-09-20 03:51:11 +0200 |
commit | e587f86d0b89c1b3a84199144d92b568d9daf220 (patch) | |
tree | 490f0ef2edcb3e45d8ad542ce93631c04b1eb652 | |
parent | c3a78d52c6edad42f05b4474c495f7201a902dca (diff) |
Fix QSGVisualDataModel test failure.
Because the list view isn't visible it won't trigger a relayout unless
forced by something like calling count() which means the test is
looking up a stale list of items.
VisualDataModel also wasn't clearing its cache when it changed the
root item and so could return an old item if the view didn't release
all items before querying a new one.
Task-number: QTBUG-21416
Change-Id: I71193e22965f30ea92d9861ccbeff30b64d58309
Reviewed-on: http://codereview.qt-project.org/4953
Reviewed-by: Qt Sanity Bot <[email protected]>
Reviewed-by: Martin Jones <[email protected]>
-rw-r--r-- | src/declarative/items/qsgvisualitemmodel.cpp | 4 | ||||
-rw-r--r-- | tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/declarative/items/qsgvisualitemmodel.cpp b/src/declarative/items/qsgvisualitemmodel.cpp index 4dd508d0aa..c6e5896373 100644 --- a/src/declarative/items/qsgvisualitemmodel.cpp +++ b/src/declarative/items/qsgvisualitemmodel.cpp @@ -984,7 +984,7 @@ void QSGVisualDataModel::setDelegate(QDeclarativeComponent *delegate) emit countChanged(); } if (wasValid && !d->m_delegate && d->modelCount()) { - emit itemsRemoved(0, d->modelCount()); + _q_itemsRemoved(0, d->modelCount()); emit countChanged(); } } @@ -1035,7 +1035,7 @@ void QSGVisualDataModel::setRootIndex(const QVariant &root) d->m_abstractItemModel->fetchMore(modelIndex); int newCount = d->modelCount(); if (d->m_delegate && oldCount) - emit itemsRemoved(0, oldCount); + _q_itemsRemoved(0, oldCount); if (d->m_delegate && newCount) emit itemsInserted(0, newCount); if (newCount != oldCount) diff --git a/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp b/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp index f8a2a1f859..d1dc6c97b9 100644 --- a/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp +++ b/tests/auto/declarative/qsgvisualdatamodel/tst_qsgvisualdatamodel.cpp @@ -274,6 +274,7 @@ void tst_qsgvisualdatamodel::childChanged() QSGVisualDataModel *vdm = listview->findChild<QSGVisualDataModel*>("visualModel"); vdm->setRootIndex(QVariant::fromValue(model.indexFromItem(model.item(1,0)))); + QCOMPARE(listview->count(), 1); QSGText *name = findItem<QSGText>(contentItem, "display", 0); QVERIFY(name); @@ -289,7 +290,7 @@ void tst_qsgvisualdatamodel::childChanged() QCOMPARE(name->text(), QString("Row 2 updated child")); model.item(1,0)->appendRow(new QStandardItem(QLatin1String("Row 2 Child Item 2"))); - QTest::qWait(300); + QCOMPARE(listview->count(), 2); name = findItem<QSGText>(contentItem, "display", 1); QVERIFY(name != 0); @@ -300,7 +301,7 @@ void tst_qsgvisualdatamodel::childChanged() QVERIFY(name == 0); vdm->setRootIndex(QVariant::fromValue(QModelIndex())); - QTest::qWait(300); + QCOMPARE(listview->count(), 3); name = findItem<QSGText>(contentItem, "display", 0); QVERIFY(name); QCOMPARE(name->text(), QString("Row 1 Item")); |