diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-13 14:10:56 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-18 13:14:00 +0200 |
commit | 2a43ec129a544d80c9cc3266b5eccce0f6ba66ef (patch) | |
tree | 4c79136b62abb0e4ddac296cee84eaabea6a58ca | |
parent | 7ad3ba2dbb396552d062c9d6d75697150bee75da (diff) |
Make QJSValue::prototype() gc safe
Change-Id: Ia93af291f97fd2b6473267e95520bc0759034029
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r-- | src/qml/jsapi/qjsvalue.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index ca2f398f2f..908e9a4519 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -663,12 +663,17 @@ QJSEngine* QJSValue::engine() const */ QJSValue QJSValue::prototype() const { - Object *o = d->value.asObject(); + QV4::ExecutionEngine *engine = d->engine; + if (!engine) + return QJSValue(); + QV4::Scope scope(engine); + Scoped<Object> o(scope, d->value.asObject()); if (!o) return QJSValue(); - if (!o->prototype()) + Scoped<Object> p(scope, o->prototype()); + if (!p) return QJSValue(NullValue); - return new QJSValuePrivate(o->internalClass->engine, Value::fromObject(o->prototype())); + return new QJSValuePrivate(o->internalClass->engine, p.asValue()); } /*! |