diff options
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index a7332d65da..6c60a9964a 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -92,6 +92,9 @@ FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, boo , varCount(0) , function(0) { + // set the name to something here, so that a gc run a few lines below doesn't crash on it + this->name = scope->engine->id_undefined; + Scope s(scope); ScopedValue protectThis(s, this); ScopedString n(s, s.engine->newString(name)); @@ -108,7 +111,7 @@ FunctionObject::FunctionObject(InternalClass *ic) , function(0) { vtbl = &static_vtbl; - name = (QV4::String *)0; + name = engine()->id_undefined; type = Type_FunctionObject; needsActivation = false; @@ -125,6 +128,7 @@ FunctionObject::~FunctionObject() void FunctionObject::init(const StringRef n, bool createProto) { vtbl = &static_vtbl; + name = n; Scope s(engine()); ScopedValue protectThis(s, this); @@ -143,13 +147,8 @@ void FunctionObject::init(const StringRef n, bool createProto) memberData[Index_Prototype].value = proto.asValue(); } - if (n) { - name = n; - ScopedValue v(s, n.asReturnedValue()); - defineReadonlyProperty(scope->engine->id_name, v); - } else { - name = (QV4::String *)0; - } + ScopedValue v(s, n.asReturnedValue()); + defineReadonlyProperty(scope->engine->id_name, v); } ReturnedValue FunctionObject::newInstance() |
