summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qjsonobject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/serialization/qjsonobject.cpp')
-rw-r--r--src/corelib/serialization/qjsonobject.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/corelib/serialization/qjsonobject.cpp b/src/corelib/serialization/qjsonobject.cpp
index 502d64d854b..014224c4db1 100644
--- a/src/corelib/serialization/qjsonobject.cpp
+++ b/src/corelib/serialization/qjsonobject.cpp
@@ -707,13 +707,12 @@ bool QJsonObject::operator!=(const QJsonObject &other) const
*/
QJsonObject::iterator QJsonObject::erase(QJsonObject::iterator it)
{
- if (it.item.o != this || qsizetype(it.item.index) >= o->elements.length())
- return {this, o->elements.length()};
-
removeAt(it.item.index);
- // iterator hasn't changed
- return it;
+ // index hasn't changed; the container pointer shouldn't have changed
+ // because we shouldn't have detached (detaching happens on obtaining a
+ // non-const iterator). But just in case we did, reload the pointer.
+ return { this, qsizetype(it.item.index) };
}
#if QT_STRINGVIEW_LEVEL < 2