From 944221001c67d01fc528f5e7a0d3b1c9578cec32 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 4 Jun 2012 18:52:36 +0200 Subject: Fixed QJsonObject::find() The function returns mutable iterator on the object that can later be passed to e.g. erase(), hence it should detach() to be consistent with QJsonObject::begin() which also detaches. Change-Id: Id79e8e012fd5469e06b68fbc9eecb7c6848ce9c1 Reviewed-by: Lars Knoll Reviewed-by: Denis Dzyubenko --- tests/auto/corelib/json/tst_qtjson.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/auto/corelib/json/tst_qtjson.cpp') diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 00810889bb..5498c890fe 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -589,6 +589,16 @@ void TestQtJson::testObjectIteration() } } + { + QJsonObject object2 = object; + QVERIFY(object == object2); + + QJsonObject::iterator it = object2.find(QString::number(5)); + object2.erase(it); + QCOMPARE(object.size(), 10); + QCOMPARE(object2.size(), 9); + } + { QJsonObject::Iterator it = object.begin(); it += 5; -- cgit v1.2.3