aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-19 16:05:25 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-22 01:06:20 +0200
commit47bf40dd49f90b52cc1b545b2be3035d48d6199e (patch)
tree9e671c23d610822ac354e4a1399e2c805cbea599 /tools
parent78b49cf8361b1462cc94a061916a15f0b98e27e3 (diff)
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 <gunnar.sletta@digia.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/v4/main.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/tools/v4/main.cpp b/tools/v4/main.cpp
index ad91b88cda..8e9a880ccd 100644
--- a/tools/v4/main.cpp
+++ b/tools/v4/main.cpp
@@ -72,9 +72,8 @@ using namespace QV4;
struct Print: FunctionObject
{
- Print(ExecutionContext *scope): FunctionObject(scope) {
+ Print(ExecutionContext *scope): FunctionObject(scope, QStringLiteral("print")) {
vtbl = &static_vtbl;
- name = scope->engine->newString("print");
}
static ReturnedValue call(Managed *, CallData *callData)
@@ -97,10 +96,9 @@ DEFINE_MANAGED_VTABLE(Print);
struct GC: public FunctionObject
{
GC(ExecutionContext* scope)
- : FunctionObject(scope)
+ : FunctionObject(scope, QStringLiteral("gc"))
{
vtbl = &static_vtbl;
- name = scope->engine->newString("gc");
}
static ReturnedValue call(Managed *m, CallData *)
{