diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-11 16:28:17 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-18 13:13:33 +0200 |
commit | bdb27b96acbd38531879378c48959a5a1cd60963 (patch) | |
tree | 056f2c8c35be97a9564dee5d0ea65bed7265b7ce /src/qml/jsapi | |
parent | 8d26084ae56ba5aedd73ab733553dbf9cb3eb672 (diff) |
Use ReturnedValue for Managed::get().
Change-Id: Ia8f35d227b69d32e1f6a041283abbbd083aa34ca
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsapi')
-rw-r--r-- | src/qml/jsapi/qjsvalue.cpp | 16 | ||||
-rw-r--r-- | src/qml/jsapi/qjsvalueiterator.cpp | 4 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index eb2390fa01..7b0b8bc2fd 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -791,11 +791,15 @@ bool QJSValue::strictlyEquals(const QJSValue& other) const */ QJSValue QJSValue::property(const QString& name) const { + ExecutionEngine *engine = d->engine; + if (!engine) + return QJSValue(); + QV4::Scope scope(engine); + Object *o = d->value.asObject(); if (!o) return QJSValue(); - ExecutionEngine *engine = d->engine; String *s = engine->newString(name); uint idx = s->asArrayIndex(); if (idx < UINT_MAX) @@ -804,7 +808,7 @@ QJSValue QJSValue::property(const QString& name) const s->makeIdentifier(); QV4::ExecutionContext *ctx = engine->current; try { - QV4::Value v = o->get(s); + QV4::ScopedValue v(scope, o->get(s)); return new QJSValuePrivate(engine, v); } catch (QV4::Exception &e) { e.accept(ctx); @@ -826,14 +830,18 @@ QJSValue QJSValue::property(const QString& name) const */ QJSValue QJSValue::property(quint32 arrayIndex) const { + ExecutionEngine *engine = d->engine; + if (!engine) + return QJSValue(); + + QV4::Scope scope(engine); Object *o = d->value.asObject(); if (!o) return QJSValue(); - ExecutionEngine *engine = d->engine; QV4::ExecutionContext *ctx = engine->current; try { - QV4::Value v = arrayIndex == UINT_MAX ? o->get(engine->id_uintMax) : o->getIndexed(arrayIndex); + QV4::ScopedValue v(scope, arrayIndex == UINT_MAX ? o->get(engine->id_uintMax) : o->getIndexed(arrayIndex).asReturnedValue()); return new QJSValuePrivate(engine, v); } catch (QV4::Exception &e) { e.accept(ctx); diff --git a/src/qml/jsapi/qjsvalueiterator.cpp b/src/qml/jsapi/qjsvalueiterator.cpp index 545250f27a..2b074c3cb2 100644 --- a/src/qml/jsapi/qjsvalueiterator.cpp +++ b/src/qml/jsapi/qjsvalueiterator.cpp @@ -174,9 +174,11 @@ QJSValue QJSValueIterator::value() const QV4::Object *o = d_ptr->iterator.object; QV4::ExecutionEngine *engine = o->internalClass->engine; + QV4::Scope scope(engine); + QV4::ExecutionContext *ctx = engine->current; try { - QV4::Value v; + QV4::ScopedValue v(scope); if (d_ptr->currentName) v = o->get(d_ptr->currentName); else if (d_ptr->currentIndex != UINT_MAX) |