aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoni Poikelin <joni.poikelin@qt.io>2020-12-14 09:18:58 +0200
committerJoni Poikelin <joni.poikelin@qt.io>2020-12-17 08:04:08 +0000
commitd99d192884608408759492bd656ab99a2f4f23ed (patch)
tree2045a4695df1aad5c7c7f5912ee837747b4d2b61 /src
parentd9a6c45a06f23cdd896e5360cc3cd3608fea4c3e (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 Pick-to: 6.0 5.15 Change-Id: I0ec1a67e822e4f8fe5b8f87f38dfae1f26b3fab5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
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 4f211aea53..303ca0e2e4 100644
--- a/src/qmlmodels/qqmldelegatemodel.cpp
+++ b/src/qmlmodels/qqmldelegatemodel.cpp
@@ -1872,6 +1872,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
@@ -1883,6 +1886,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)