Remove default parenting in Qt.createComponent()
authorMatthew Vogt <matthew.vogt@nokia.com>
Wed, 23 May 2012 06:12:44 +0000 (16:12 +1000)
committerQt by Nokia <qt-info@nokia.com>
Wed, 23 May 2012 22:23:43 +0000 (00:23 +0200)
Remove the default parent applied to component instances created by
Qt.createComponent().  This allows these objects to be managed by usual
JS reference management, and thus to be appropriately garbage
collected.

Task-number: QTBUG-24841
Change-Id: I29efbb9d8f5a2ef4c74415399fa3024e6590004b
Reviewed-by: Chris Adams <christopher.adams@nokia.com>

src/qml/qml/v8/qqmlbuiltinfunctions.cpp
tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp

index dd5131f..f6c7a59 100644 (file)
@@ -1137,9 +1137,7 @@ v8::Handle<v8::Value> createComponent(const v8::Arguments &args)
         return v8::Null();
 
     QQmlComponent::CompilationMode compileMode = QQmlComponent::PreferSynchronous;
-
-    // Default to engine parent; this will be removed in the near future (QTBUG-24841)
-    QObject *parentArg = engine;
+    QObject *parentArg = 0;
 
     int consumedCount = 1;
     if (args.Length() > 1) {
index 26bf918..9d7d289 100644 (file)
@@ -1409,12 +1409,9 @@ void tst_qqmlecmascript::componentCreation()
         QVERIFY(created);
 
         QObject *expectedParent;
-        if (createdParent.isEmpty()) {
-            // For now, the parent should be the engine; this will change for QTBUG-24841
-            expectedParent = &engine;
-        } else if (createdParent == QLatin1String("obj")) {
+        if (createdParent == QLatin1String("obj")) {
             expectedParent = object;
-        } else if (createdParent == QLatin1String("null")) {
+        } else if ((createdParent == QLatin1String("null")) || createdParent.isEmpty()) {
             expectedParent = 0;
         }
         QCOMPARE(created->parent(), expectedParent);