diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-11 21:48:23 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-18 13:13:36 +0200 |
commit | 6c9f1c8ed93374c16ca6ac540f39e98b451be0d8 (patch) | |
tree | 476d0046c6016a8cd62bfc29ed9697d98e98f738 /src/qml/qml/qqmlvmemetaobject.cpp | |
parent | bdb27b96acbd38531879378c48959a5a1cd60963 (diff) |
Use a ReturnedValue for Managed::getIndexed()
Change-Id: I0371ed21c4ef99564d3ffa1082dd109e890a78bf
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlvmemetaobject.cpp')
-rw-r--r-- | src/qml/qml/qqmlvmemetaobject.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index f8c2590a20..360528ea7a 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -992,7 +992,7 @@ QV4::Value QQmlVMEMetaObject::readVarProperty(int id) Q_ASSERT(id >= firstVarPropertyIndex); if (ensureVarPropertiesAllocated()) - return varProperties.value().asObject()->getIndexed(id - firstVarPropertyIndex); + return QV4::Value::fromReturnedValue(varProperties.value().asObject()->getIndexed(id - firstVarPropertyIndex)); return QV4::Value::emptyValue(); } @@ -1001,7 +1001,7 @@ QVariant QQmlVMEMetaObject::readPropertyAsVariant(int id) if (id >= firstVarPropertyIndex) { if (ensureVarPropertiesAllocated()) return QQmlEnginePrivate::get(ctxt->engine)->v8engine()->toVariant( - varProperties.value().asObject()->getIndexed(id - firstVarPropertyIndex), -1); + QV4::Value::fromReturnedValue(varProperties.value().asObject()->getIndexed(id - firstVarPropertyIndex)), -1); return QVariant(); } else { if (data[id].dataType() == QMetaType::QObjectStar) { @@ -1018,11 +1018,12 @@ void QQmlVMEMetaObject::writeVarProperty(int id, const QV4::Value &value) if (!ensureVarPropertiesAllocated()) return; + QV4::Scope scope(varProperties.engine()); // Importantly, if the current value is a scarce resource, we need to ensure that it // gets automatically released by the engine if no other references to it exist. - QV4::Value oldv = varProperties.value().asObject()->getIndexed(id - firstVarPropertyIndex); - if (QV4::VariantObject *v = oldv.as<QV4::VariantObject>()) - v->removeVmePropertyReference(); + QV4::Scoped<QV4::VariantObject> oldv(scope, varProperties.value().asObject()->getIndexed(id - firstVarPropertyIndex)); + if (!!oldv) + oldv->removeVmePropertyReference(); QObject *valueObject = 0; QQmlVMEVariantQObjectPtr *guard = getQObjectGuardForProperty(id); @@ -1059,11 +1060,13 @@ void QQmlVMEMetaObject::writeProperty(int id, const QVariant &value) if (!ensureVarPropertiesAllocated()) return; + QV4::Scope scope(varProperties.engine()); + // Importantly, if the current value is a scarce resource, we need to ensure that it // gets automatically released by the engine if no other references to it exist. - QV4::Value oldv = varProperties.value().asObject()->getIndexed(id - firstVarPropertyIndex); - if (QV4::VariantObject *v = oldv.as<QV4::VariantObject>()) - v->removeVmePropertyReference(); + QV4::Scoped<QV4::VariantObject> oldv(scope, varProperties.value().asObject()->getIndexed(id - firstVarPropertyIndex)); + if (!!oldv) + oldv->removeVmePropertyReference(); // And, if the new value is a scarce resource, we need to ensure that it does not get // automatically released by the engine until no other references to it exist. |