From: Matthew Vogt Date: Wed, 23 May 2012 06:12:44 +0000 (+1000) Subject: Remove default parenting in Qt.createComponent() X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=e574e9adcac1244db5c828575553a63ccbdd28b9;p=konrad%2Fqtdeclarative.git Remove default parenting in Qt.createComponent() 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 --- diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index dd5131f..f6c7a59 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1137,9 +1137,7 @@ v8::Handle 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) { diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 26bf918..9d7d289 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -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);