aboutsummaryrefslogtreecommitdiffstats
path: root/src
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 /src
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 'src')
-rw-r--r--src/quick/items/qquicktableview.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp
index 73857af558..ab57a8ea0b 100644
--- a/src/quick/items/qquicktableview.cpp
+++ b/src/quick/items/qquicktableview.cpp
@@ -1786,10 +1786,12 @@ void QQuickTableViewPrivate::beginRebuildTable()
QPointF topLeftPos;
calculateTopLeft(topLeft, topLeftPos);
- if (rebuildOptions & RebuildOption::All)
- releaseLoadedItems(QQmlTableInstanceModel::NotReusable);
- else if (rebuildOptions & RebuildOption::ViewportOnly)
- releaseLoadedItems(reusableFlag);
+ if (!loadedItems.isEmpty()) {
+ if (rebuildOptions & RebuildOption::All)
+ releaseLoadedItems(QQmlTableInstanceModel::NotReusable);
+ else if (rebuildOptions & RebuildOption::ViewportOnly)
+ releaseLoadedItems(reusableFlag);
+ }
if (rebuildOptions & RebuildOption::All) {
origin = QPointF(0, 0);
@@ -2237,8 +2239,10 @@ void QQuickTableViewPrivate::syncModel()
if (modelVariant == assignedModel)
return;
- if (model)
+ if (model) {
disconnectFromModel();
+ releaseLoadedItems(QQmlTableInstanceModel::NotReusable);
+ }
modelVariant = assignedModel;
QVariant effectiveModelVariant = modelVariant;
@@ -2249,7 +2253,6 @@ void QQuickTableViewPrivate::syncModel()
if (instanceModel) {
if (tableModel) {
- releaseLoadedItems(QQmlTableInstanceModel::NotReusable);
delete tableModel;
tableModel = nullptr;
}