aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoni Poikelin <joni.poikelin@qt.io>2020-12-14 09:18:58 +0200
committerTarja Sundqvist <tarja.sundqvist@qt.io>2021-02-09 10:55:19 +0200
commit1cbaf1b043fd650ed6aa96e441554c6644e9039e (patch)
tree253d6aea83794a79e2c8651bfa9a16e1f8d8306c /src
parentb4e57491311ccbcc9da09a5d04e1fc6cec397a41 (diff)
Fix crash during model reset
Commit 37fcffa035d55ac00f85f57ce1390fff3be213c6 fixed the issue for remove rows, but it can also happen with model reset. Fixes: QTBUG-83352 Change-Id: I0ec1a67e822e4f8fe5b8f87f38dfae1f26b3fab5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit d99d192884608408759492bd656ab99a2f4f23ed)
Diffstat (limited to 'src')
-rw-r--r--src/qmlmodels/qqmldelegatemodel.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp
index 0583b9708d..5ad56a1710 100644
--- a/src/qmlmodels/qqmldelegatemodel.cpp
+++ b/src/qmlmodels/qqmldelegatemodel.cpp
@@ -1875,6 +1875,9 @@ void QQmlDelegateModel::_q_modelReset()
d->m_count = d->adaptorModelCount();
const QList<QQmlDelegateModelItem *> cache = d->m_cache;
+ for (QQmlDelegateModelItem *item : cache)
+ item->referenceObject();
+
for (int i = 0, c = cache.count(); i < c; ++i) {
QQmlDelegateModelItem *item = cache.at(i);
// layout change triggered by changing the modelIndex might have
@@ -1886,6 +1889,8 @@ void QQmlDelegateModel::_q_modelReset()
item->setModelIndex(-1, -1, -1);
}
+ for (QQmlDelegateModelItem *item : cache)
+ item->releaseObject();
QVector<Compositor::Remove> removes;
QVector<Compositor::Insert> inserts;
if (oldCount)