aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoni Poikelin <joni.poikelin@qt.io>2020-12-14 09:18:58 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-12-17 14:05:22 +0000
commite4290a332d795257db01a1a8c175d69ec5cf8113 (patch)
tree2278778b364c980c6771d453f4f98427d7a5ad52 /src
parent90307d688e8485c143ba291685aa847fb571f6fb (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) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
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)