From 75ba1ce9114e320cccfbc0c14dd32675ce2e598e Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 2 Jul 2019 16:21:42 +0200 Subject: QQmlAdapterModel: Guard items against deletion during notification Change-Id: I177ea278b5039688923fc23425a1377522412d08 Reviewed-by: Simon Hausmann --- src/qml/util/qqmladaptormodel.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp index a9a38c5381..1ff866eb74 100644 --- a/src/qml/util/qqmladaptormodel.cpp +++ b/src/qml/util/qqmladaptormodel.cpp @@ -162,8 +162,14 @@ public: signalIndexes.append(propertyId + signalOffset); } - for (int i = 0, c = items.count(); i < c; ++i) { - QQmlDelegateModelItem *item = items.at(i); + QVarLengthArray> guardedItems; + for (const auto item : items) + guardedItems.append(item); + + for (const auto &item : qAsConst(guardedItems)) { + if (item.isNull()) + continue; + const int idx = item->modelIndex(); if (idx >= index && idx < index + count) { for (int i = 0; i < signalIndexes.count(); ++i) -- cgit v1.2.3