From 47bf40dd49f90b52cc1b545b2be3035d48d6199e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 19 Sep 2013 16:05:25 +0200 Subject: Prevent objects from being collected while in their constructor While objects are being constructed, we don't have a reference to them on the JS stack yet. So the constructor needs to protect itself against being collected by putting the this object onto the JS stack. Added an environment switch MM_EXACT_GC to test exact garbage collection. Change-Id: Ie37665a954de800359c272ffbebbe1488e7a8ace Reviewed-by: Gunnar Sletta Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4function.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/qml/jsruntime/qv4function.cpp') diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp index f69a095991..a39050aaf2 100644 --- a/src/qml/jsruntime/qv4function.cpp +++ b/src/qml/jsruntime/qv4function.cpp @@ -53,8 +53,7 @@ using namespace QV4; Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function, ReturnedValue (*codePtr)(ExecutionContext *, const uchar *), quint32 _codeSize) - : name(0) - , compiledFunction(function) + : compiledFunction(function) , compilationUnit(unit) , codePtr(codePtr) , codeData(0) @@ -81,8 +80,8 @@ Function::~Function() void Function::mark() { - if (name) - name->mark(); + if (name.asManaged()) + name.asManaged()->mark(); for (int i = 0; i < formals.size(); ++i) formals.at(i)->mark(); for (int i = 0; i < locals.size(); ++i) -- cgit v1.2.3