diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-07-29 12:49:37 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-07-29 12:49:37 +0200 |
commit | 8b88e37bf79a53eb0cb34226aacb25ad9b01d7cf (patch) | |
tree | 6087ee08b55f69f9c4981d9026d3162f2ee50c31 /tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | |
parent | 61edb86ed4cc0ac31d77d3793936fa1e8476b504 (diff) | |
parent | 7ceca6ac0535a957e9f87f789119c288f6d93837 (diff) |
Merge remote-tracking branch 'origin/5.3' into dev
Change-Id: Id95f7b01de36bccecbb7b73acc041654a1fe2ebe
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index d068584797..6b37163b40 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -324,6 +324,7 @@ private slots: void varPropertyAccessOnObjectWithInvalidContext(); void importedScriptsAccessOnObjectWithInvalidContext(); void contextObjectOnLazyBindings(); + void garbageCollectionDuringCreation(); private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); @@ -7637,6 +7638,33 @@ void tst_qqmlecmascript::contextObjectOnLazyBindings() QCOMPARE(subObject->property("testValue").toInt(), int(42)); } +void tst_qqmlecmascript::garbageCollectionDuringCreation() +{ + QQmlComponent component(&engine); + component.setData("import Qt.test 1.0\n" + "QObjectContainerWithGCOnAppend {\n" + " objectName: \"root\"\n" + " FloatingQObject {\n" + " objectName: \"parentLessChild\"\n" + " property var blah;\n" // Ensure we have JS wrapper + " }\n" + "}\n", + QUrl()); + + QScopedPointer<QObject> object(component.create()); + QVERIFY(!object.isNull()); + + QObjectContainer *container = qobject_cast<QObjectContainer*>(object.data()); + QCOMPARE(container->dataChildren.count(), 1); + + QObject *child = container->dataChildren.first(); + QQmlData *ddata = QQmlData::get(child); + QVERIFY(!ddata->jsWrapper.isNullOrUndefined()); + + gc(engine); + QCOMPARE(container->dataChildren.count(), 0); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" |