aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2019-12-05 15:29:29 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2019-12-09 14:16:07 +0100
commitf60f2aaa5176ca703fa01fbaf01059fe989c0029 (patch)
tree54ba9a24ac9af8a436545aa6f0f66be79eb2370b /tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
parent6bc4d55fe196a6310cadb239c6069ad2ea044d05 (diff)
QQuickTableView: ensure we release items in the old model and not the new
As it stood, we would wait to release loaded items until we started the rebuild process, if the old model was a DelegateModel. But at that time, the model would alread have been changed, so we would release the items by calling out to the wrong model. This patch will ensure that we always release the items immediately when syncing the model, which will also cover the case when the model is a DelegateModel. Fixes: QTBUG-80570 Change-Id: I1b06011f4795727d04d9cd8c20381f65552b8fe8 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktableview/tst_qquicktableview.cpp')
-rw-r--r--tests/auto/quick/qquicktableview/tst_qquicktableview.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
index 09d1b8ca7c..405524b704 100644
--- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
+++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp
@@ -2705,14 +2705,20 @@ void tst_QQuickTableView::replaceModel()
{
LOAD_TABLEVIEW("replaceModelTableView.qml");
- tableView->setProperty("modelId", 0);
+ const auto objectModel = view->rootObject()->property("objectModel");
+ const auto listModel = view->rootObject()->property("listModel");
+ const auto delegateModel = view->rootObject()->property("delegateModel");
+
+ tableView->setModel(listModel);
QTRY_COMPARE(tableView->rows(), 2);
- tableView->setProperty("modelId", 1);
+ tableView->setModel(objectModel);
QTRY_COMPARE(tableView->rows(), 3);
- tableView->setProperty("modelId", 2);
+ tableView->setModel(delegateModel);
QTRY_COMPARE(tableView->rows(), 2);
- tableView->setProperty("modelId", 0);
+ tableView->setModel(listModel);
QTRY_COMPARE(tableView->rows(), 2);
+ tableView->setModel(QVariant());
+ QTRY_COMPARE(tableView->rows(), 0);
}
QTEST_MAIN(tst_QQuickTableView)