From ba29371b9415e5a3d970edfbf6b3696b6a7f7b89 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 4 Jun 2013 15:42:38 +0200 Subject: [PATCH] Cleanup: Get rid of v8engine pointer in QObjectWrapper Change-Id: I3a077c6a8ed61ce6dc6a06cf4c4d181509ee8565 Reviewed-by: Lars Knoll --- src/qml/qml/v8/qv8qobjectwrapper.cpp | 15 ++++++++------- src/qml/qml/v8/qv8qobjectwrapper_p.h | 4 +--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp index 091a952..c5d9b22 100644 --- a/src/qml/qml/v8/qv8qobjectwrapper.cpp +++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp @@ -88,7 +88,6 @@ QObjectWrapper::QObjectWrapper(ExecutionEngine *engine, QObject *object) : Object(engine) , m_object(object) { - this->v8Engine = QV8Engine::get(engine->publicEngine); vtbl = &static_vtbl; prototype = engine->objectPrototype; @@ -145,6 +144,7 @@ Value QObjectWrapper::getQmlProperty(ExecutionContext *ctx, String *name, QObjec } QHashedV4String propertystring(QV4::Value::fromString(name)); + QV8Engine *v8Engine = QV8Engine::get(ctx->engine->publicEngine); QQmlContextData *context = QV4::QmlContextWrapper::callingContext(ctx->engine); @@ -204,8 +204,8 @@ void QObjectWrapper::put(Managed *m, ExecutionContext *ctx, String *name, const QHashedV4String propertystring(QV4::Value::fromString(name)); - QV8Engine *v8engine = that->v8Engine; - QQmlContextData *context = v8engine->callingContext(); + QQmlContextData *context = QV4::QmlContextWrapper::callingContext(ctx->engine); + QV8Engine *v8engine = QV8Engine::get(ctx->engine->publicEngine); bool result = QV8QObjectWrapper::SetProperty(v8engine, object, propertystring, context, value, QV4::QObjectWrapper::IgnoreRevision); if (!result) { @@ -224,8 +224,9 @@ QV4::Value QObjectWrapper::enumerateProperties(Object *object) QStringList result; - QQmlEnginePrivate *ep = that->v8Engine->engine() - ? QQmlEnginePrivate::get(that->v8Engine->engine()) + QV8Engine *v8Engine = QV8Engine::get(that->engine()->publicEngine); + QQmlEnginePrivate *ep = v8Engine->engine() + ? QQmlEnginePrivate::get(v8Engine->engine()) : 0; QQmlPropertyCache *cache = 0; @@ -744,7 +745,7 @@ static void FastValueSetter(v8::Handle, v8::Handle value, Q_ASSERT(pdata->isWritable() || pdata->isQList()); - StoreProperty(wrapper->v8Engine, object, pdata, value); + StoreProperty(QV8Engine::get(wrapper->engine()->publicEngine), object, pdata, value); } static void FastValueSetterReadOnly(v8::Handle property, v8::Handle, @@ -755,7 +756,7 @@ static void FastValueSetterReadOnly(v8::Handle property, v8::Handle< if (QQmlData::wasDeleted(wrapper->object())) return; - QV8Engine *v8engine = wrapper->v8Engine; + QV8Engine *v8engine = QV8Engine::get(wrapper->engine()->publicEngine); QString error = QLatin1String("Cannot assign to read-only property \"") + property->v4Value().toQString() + QLatin1Char('\"'); diff --git a/src/qml/qml/v8/qv8qobjectwrapper_p.h b/src/qml/qml/v8/qv8qobjectwrapper_p.h index 72bf750..17e50fd 100644 --- a/src/qml/qml/v8/qv8qobjectwrapper_p.h +++ b/src/qml/qml/v8/qv8qobjectwrapper_p.h @@ -86,8 +86,6 @@ struct Q_QML_EXPORT QObjectWrapper : public QV4::Object ~QObjectWrapper(); - QV8Engine *v8Engine; // ### Remove again. - QObject *object() const { return m_object.data(); } void deleteQObject(bool deleteInstantly = false); @@ -98,7 +96,7 @@ struct Q_QML_EXPORT QObjectWrapper : public QV4::Object static Value wrap(ExecutionEngine *engine, QQmlData *ddata, QObject *object); private: - QObjectWrapper(ExecutionEngine *v8Engine, QObject *object); + QObjectWrapper(ExecutionEngine *engine, QObject *object); QQmlGuard m_object; String *m_destroy; -- 2.7.4