Protect a few constructors against self destruction
authorLars Knoll <lars.knoll@digia.com>
Thu, 10 Oct 2013 17:52:49 +0000 (19:52 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 11 Oct 2013 06:56:29 +0000 (08:56 +0200)
This gets most of qqmlecmascript to pass with aggressive and
exact garbage collection.

Change-Id: I93ecbfe55f62af68227cdf3b1ec2bd066f1cbdef
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/jsruntime/qv4argumentsobject.cpp
src/qml/qml/v8/qqmlbuiltinfunctions.cpp

index 39d6954..c815036 100644 (file)
@@ -52,8 +52,9 @@ ArgumentsObject::ArgumentsObject(CallContext *context)
     vtbl = &static_vtbl;
     type = Type_ArgumentsObject;
 
-    Scope scope(context);
     ExecutionEngine *v4 = context->engine;
+    Scope scope(v4);
+    ScopedObject protectThis(scope, this);
 
     if (context->strictMode) {
         internalClass = v4->strictArgumentsObjectClass;
index ba5f05b..f9aca08 100644 (file)
@@ -93,6 +93,7 @@ QV4::QtObject::QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine)
     vtbl = &static_vtbl;
 
     Scope scope(v4);
+    ScopedObject protectThis(scope, this);
 
     // Set all the enums from the "Qt" namespace
     const QMetaObject *qtMetaObject = StaticQtMetaObject::get();
@@ -1313,6 +1314,9 @@ ReturnedValue QtObject::method_get_inputMethod(SimpleCallContext *ctx)
 QV4::ConsoleObject::ConsoleObject(ExecutionEngine *v4)
     : Object(v4)
 {
+    QV4::Scope scope(v4);
+    QV4::ScopedObject protectThis(scope, this);
+
     defineDefaultProperty(QStringLiteral("debug"), method_log);
     defineDefaultProperty(QStringLiteral("log"), method_log);
     defineDefaultProperty(QStringLiteral("info"), method_log);