diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-07-02 16:21:42 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-07-03 11:42:24 +0200 |
commit | 75ba1ce9114e320cccfbc0c14dd32675ce2e598e (patch) | |
tree | e74fa183cee30ef07d9dd6c790fe2a1cdd321be6 /src/qml | |
parent | d73497f136fbfad5d367e5af429adb7d38af6dfe (diff) |
QQmlAdapterModel: Guard items against deletion during notification
Change-Id: I177ea278b5039688923fc23425a1377522412d08
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/util/qqmladaptormodel.cpp | 10 |
1 files 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<QQmlGuard<QQmlDelegateModelItem>> 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) |