diff options
author | Lars Knoll <[email protected]> | 2019-10-31 21:17:10 +0100 |
---|---|---|
committer | Lars Knoll <[email protected]> | 2019-11-01 17:03:00 +0100 |
commit | cff6a7b4bfed0256dededf9cb87905081d44bdb2 (patch) | |
tree | d9799085dd6cd93619c5ef8187ff95b01a7c736f /src/qmlmodels/qqmlobjectmodel.cpp | |
parent | 7213a0d5e5454555e44a2b1d8cdac0490c1e5ab9 (diff) |
Take a copy of the children list before emitting the destroyingItem signal
clear() emits a signal for each item that is being destroyed. Unfortunately
that signal can be connected to some other place that already removes
the item indirectly. In that case, we would not correctly emit the
destroyed signal for all items, leading to errors later on.
Fixes a test failure in Qt Quick Controls 2
Change-Id: I3aff75d9263badd9f87883610c7a00a94ee823d3
Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qmlmodels/qqmlobjectmodel.cpp')
-rw-r--r-- | src/qmlmodels/qqmlobjectmodel.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/qmlmodels/qqmlobjectmodel.cpp b/src/qmlmodels/qqmlobjectmodel.cpp index c833206525..8e7b0a9b5f 100644 --- a/src/qmlmodels/qqmlobjectmodel.cpp +++ b/src/qmlmodels/qqmlobjectmodel.cpp @@ -154,7 +154,8 @@ public: void clear() { Q_Q(QQmlObjectModel); - for (const Item &child : qAsConst(children)) + const auto copy = children; + for (const Item &child : copy) emit q->destroyingItem(child.item); remove(0, children.count()); } @@ -170,6 +171,8 @@ public: QList<Item> children; }; +Q_DECLARE_TYPEINFO(QQmlObjectModelPrivate::Item, Q_PRIMITIVE_TYPE); + /*! \qmltype ObjectModel |