diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2012-06-04 18:48:51 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-13 23:58:51 +0100 |
commit | 6b5b5d4e530eef3f5a7025f753d6f54e76ad008f (patch) | |
tree | 59d23254a80c9dbb12c3061c9172c6a4ca48380a /src | |
parent | 20d6a0bfbcd10c3954e675adbcbd22b524ba7f04 (diff) |
Added missing detach() to QJsonObject::take()
We also need to detach() the taken value in case the compaction triggers and
modifies the underlaying data.
Change-Id: Idcdeba4236b8e208d107d41be2decbdfc5721300
Reviewed-by: Bjørn Erik Nilsen <post@bjoernen.com>
Reviewed-by: Denis Dzyubenko <denis@ddenis.info>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/json/qjsonobject.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp index e595753fec..1bdd872e78 100644 --- a/src/corelib/json/qjsonobject.cpp +++ b/src/corelib/json/qjsonobject.cpp @@ -390,13 +390,14 @@ QJsonValue QJsonObject::take(const QString &key) if (!keyExists) return QJsonValue(QJsonValue::Undefined); - QJsonPrivate::Entry *e = o->entryAt(index); + QJsonValue v(d, o, o->entryAt(index)->value); + detach(); o->removeItems(index, 1); ++d->compactionCounter; if (d->compactionCounter > 32u && d->compactionCounter >= unsigned(o->length) / 2u) compact(); - return QJsonValue(d, o, e->value); + return v; } /*! |