diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-23 15:52:10 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-26 09:05:16 +0200 |
commit | 12fd2ccd3fa2dc0133b5a3fb89f9fdf5cf721232 (patch) | |
tree | 880acb9c7c0d8289185b6aebe4339f439c707a0e /src/qml/qml/qqmlcomponent.cpp | |
parent | 2e4f66caa8a5f9e887dbdb4e3f2ae5c9be9a7005 (diff) |
Fix Persistent/WeakValue API
Don't use unprotected Values in the API anymore.
Change-Id: I8851628227fca374de24701bc8ee0908b5ae3923
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlcomponent.cpp')
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index cf3493a590..cfda595438 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1123,7 +1123,7 @@ public: QV8Engine *v8; QPointer<QObject> parent; QV4::Value valuemap; - QV4::Value qmlGlobal; + QV4::SafeValue qmlGlobal; QV4::Value m_statusChanged; protected: virtual void statusChanged(Status); @@ -1244,7 +1244,8 @@ void QQmlComponent::createObject(QQmlV4Function *args) if (!valuemap.isUndefined()) { QQmlComponentExtension *e = componentExtension(v8engine); - QV4::ScopedValue f(scope, QV4::Script::evaluate(v4engine, QString::fromLatin1(INITIALPROPERTIES_SOURCE), args->qmlGlobal().asObject())); + QV4::ScopedObject qmlglobal(scope, args->qmlGlobal()); + QV4::ScopedValue f(scope, QV4::Script::evaluate(v4engine, QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlglobal)); Q_ASSERT(f->asFunctionObject()); QV4::ScopedCallData callData(scope, 2); callData->thisObject = QV4::Value::fromObject(v4engine->globalObject); @@ -1329,9 +1330,11 @@ void QQmlComponent::incubateObject(QQmlV4Function *args) Q_ASSERT(d->engine); Q_UNUSED(d); Q_ASSERT(args); + QV4::ExecutionEngine *v4 = QV8Engine::getV4(args->engine()); + QV4::Scope scope(v4); QObject *parent = 0; - QV4::Value valuemap = QV4::Value::undefinedValue(); + QV4::ScopedValue valuemap(scope, QV4::Value::undefinedValue()); QQmlIncubator::IncubationMode mode = QQmlIncubator::Asynchronous; if (args->length() >= 1) { @@ -1340,9 +1343,9 @@ void QQmlComponent::incubateObject(QQmlV4Function *args) } if (args->length() >= 2) { - QV4::Value v = (*args)[1]; - if (v.isNull()) { - } else if (!v.asObject() || v.asArrayObject()) { + QV4::ScopedValue v(scope, (*args)[1]); + if (v->isNull()) { + } else if (!v->asObject() || v->asArrayObject()) { qmlInfo(this) << tr("createObject: value is not an object"); args->setReturnValue(QV4::Value::nullValue()); return; @@ -1361,27 +1364,27 @@ void QQmlComponent::incubateObject(QQmlV4Function *args) QQmlComponentExtension *e = componentExtension(args->engine()); - QV4::ExecutionEngine *v4 = QV8Engine::getV4(args->engine()); - QmlIncubatorObject *r = new (v4->memoryManager) QmlIncubatorObject(args->engine(), mode); - r->setPrototype(e->incubationProto.value().asObject()); + QV4::Scoped<QmlIncubatorObject> r(scope, new (v4->memoryManager) QmlIncubatorObject(args->engine(), mode)); + QV4::ScopedObject p(scope, e->incubationProto.value()); + r->setPrototype(p.getPointer()); - if (!valuemap.isUndefined()) { + if (!valuemap->isUndefined()) { r->valuemap = valuemap; r->qmlGlobal = args->qmlGlobal(); } r->parent = parent; - create(*r, creationContext()); + create(*r.getPointer(), creationContext()); if (r->status() == QQmlIncubator::Null) { args->setReturnValue(QV4::Value::nullValue()); } else { - args->setReturnValue(QV4::Value::fromObject(r)); + args->setReturnValue(r.asValue()); } } // XXX used by QSGLoader -void QQmlComponentPrivate::initializeObjectWithInitialProperties(const QV4::Value &qmlGlobal, const QV4::Value &valuemap, QObject *toCreate) +void QQmlComponentPrivate::initializeObjectWithInitialProperties(const QV4::ValueRef qmlGlobal, const QV4::Value &valuemap, QObject *toCreate) { QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); QV8Engine *v8engine = ep->v8engine(); @@ -1393,8 +1396,9 @@ void QQmlComponentPrivate::initializeObjectWithInitialProperties(const QV4::Valu if (!valuemap.isUndefined()) { QQmlComponentExtension *e = componentExtension(v8engine); + QV4::ScopedObject qmlGlobalObj(scope, qmlGlobal); QV4::Scoped<QV4::FunctionObject> f(scope, QV4::Script::evaluate(QV8Engine::getV4(v8engine), - QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlGlobal.asObject())); + QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlGlobalObj)); QV4::ScopedCallData callData(scope, 2); callData->thisObject = QV4::Value::fromObject(v4engine->globalObject); callData->args[0] = object; @@ -1490,7 +1494,7 @@ void QmlIncubatorObject::setInitialState(QObject *o) QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8); QV4::Scope scope(v4); - QV4::Scoped<QV4::FunctionObject> f(scope, QV4::Script::evaluate(v4, QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlGlobal.asObject())); + QV4::Scoped<QV4::FunctionObject> f(scope, QV4::Script::evaluate(v4, QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlGlobal)); QV4::ScopedCallData callData(scope, 2); callData->thisObject = QV4::Value::fromObject(v4->globalObject); callData->args[0] = QV4::Value::fromReturnedValue(QV4::QObjectWrapper::wrap(v4, o)); |