summaryrefslogtreecommitdiff
path: root/tests/auto/qscriptvalueiterator
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-05-11 13:25:21 +0200
committerKent Hansen <khansen@trolltech.com>2009-05-11 13:28:12 +0200
commit60ff41273a58835466022f91d4f6eb195953c739 (patch)
tree5c351cd1cfbf87bb390365d30c1e274a428b8e18 /tests/auto/qscriptvalueiterator
parent887b6074e149d5302316eb57b908c051955fa4f6 (diff)
downloadqt4-tools-60ff41273a58835466022f91d4f6eb195953c739.tar.gz
Don't leak memory when assigning scriptvalue to iterator
The d-pointer was not deleted as it should be. Reviewed-by: Harald Fernengel
Diffstat (limited to 'tests/auto/qscriptvalueiterator')
-rw-r--r--tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp b/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp
index 1413b0d6c2..257ec0bd4a 100644
--- a/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp
+++ b/tests/auto/qscriptvalueiterator/tst_qscriptvalueiterator.cpp
@@ -68,6 +68,7 @@ private slots:
void iterateString();
void iterateGetterSetter();
void iterateArgumentsObject();
+ void assignObjectToIterator();
void undefinedBehavior();
};
@@ -562,5 +563,37 @@ void tst_QScriptValueIterator::undefinedBehavior()
QVERIFY(it.value().isNumber());
}
+void tst_QScriptValueIterator::assignObjectToIterator()
+{
+ QScriptEngine eng;
+ QScriptValue obj1 = eng.newObject();
+ obj1.setProperty("foo", 123);
+ QScriptValue obj2 = eng.newObject();
+ obj2.setProperty("bar", 456);
+
+ QScriptValueIterator it(obj1);
+ QVERIFY(it.hasNext());
+ it.next();
+ it = obj2;
+ QVERIFY(it.hasNext());
+ it.next();
+ QCOMPARE(it.name(), QString::fromLatin1("bar"));
+
+ it = obj1;
+ QVERIFY(it.hasNext());
+ it.next();
+ QCOMPARE(it.name(), QString::fromLatin1("foo"));
+
+ it = obj2;
+ QVERIFY(it.hasNext());
+ it.next();
+ QCOMPARE(it.name(), QString::fromLatin1("bar"));
+
+ it = obj2;
+ QVERIFY(it.hasNext());
+ it.next();
+ QCOMPARE(it.name(), QString::fromLatin1("bar"));
+}
+
QTEST_MAIN(tst_QScriptValueIterator)
#include "tst_qscriptvalueiterator.moc"