Don't store a v8engine pointer in qqmllistwrapper
authorLars Knoll <lars.knoll@theqtcompany.com>
Tue, 30 Dec 2014 09:59:43 +0000 (10:59 +0100)
committerLars Knoll <lars.knoll@digia.com>
Thu, 1 Jan 2015 20:36:44 +0000 (21:36 +0100)
Change-Id: I21b055deb74aafff8b2ee1cdce776e06f154dcaa
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/jsruntime/qv4qobjectwrapper.cpp
src/qml/qml/qqmlcontextwrapper.cpp
src/qml/qml/qqmllistwrapper.cpp
src/qml/qml/qqmllistwrapper_p.h
src/qml/qml/v8/qv8engine.cpp

index 1af82ff..5ade6e1 100644 (file)
@@ -159,7 +159,7 @@ static QV4::ReturnedValue LoadProperty(QV8Engine *engine, QObject *object,
         ReadFunction(object, property, &rv, notifier);
         return QV4::QObjectWrapper::wrap(v4, rv);
     } else if (property.isQList()) {
-        return QmlListWrapper::create(engine, object, property.coreIndex, property.propType);
+        return QmlListWrapper::create(v4, object, property.coreIndex, property.propType);
     } else if (property.propType == QMetaType::QReal) {
         qreal v = 0;
         ReadFunction(object, property, &v, notifier);
index 7e386ac..98b72c6 100644 (file)
@@ -229,7 +229,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty
                         QQmlListProperty<QObject> prop(context->asQQmlContext(), (void*) qintptr(propertyIdx),
                                                                QQmlContextPrivate::context_count,
                                                                QQmlContextPrivate::context_at);
-                        return QmlListWrapper::create(engine, prop, qMetaTypeId<QQmlListProperty<QObject> >());
+                        return QmlListWrapper::create(v4, prop, qMetaTypeId<QQmlListProperty<QObject> >());
                     } else {
                         return engine->fromVariant(cp->propertyValues.at(propertyIdx));
                     }
index d27ed95..f80d268 100644 (file)
@@ -45,13 +45,12 @@ using namespace QV4;
 
 DEFINE_OBJECT_VTABLE(QmlListWrapper);
 
-Heap::QmlListWrapper::QmlListWrapper(QV8Engine *engine)
-    : Heap::Object(QV8Engine::getV4(engine))
-    , v8(engine)
+Heap::QmlListWrapper::QmlListWrapper(ExecutionEngine *engine)
+    : Heap::Object(engine)
 {
     setVTable(QV4::QmlListWrapper::staticVTable());
 
-    QV4::Scope scope(QV8Engine::getV4(engine));
+    QV4::Scope scope(engine);
     QV4::ScopedObject o(scope, this);
     o->setArrayType(Heap::ArrayData::Custom);
 }
@@ -60,15 +59,14 @@ Heap::QmlListWrapper::~QmlListWrapper()
 {
 }
 
-ReturnedValue QmlListWrapper::create(QV8Engine *v8, QObject *object, int propId, int propType)
+ReturnedValue QmlListWrapper::create(ExecutionEngine *engine, QObject *object, int propId, int propType)
 {
     if (!object || propId == -1)
         return Encode::null();
 
-    ExecutionEngine *v4 = QV8Engine::getV4(v8);
-    Scope scope(v4);
+    Scope scope(engine);
 
-    Scoped<QmlListWrapper> r(scope, v4->memoryManager->alloc<QmlListWrapper>(v8));
+    Scoped<QmlListWrapper> r(scope, engine->memoryManager->alloc<QmlListWrapper>(engine));
     r->d()->object = object;
     r->d()->propertyType = propType;
     void *args[] = { &r->d()->property, 0 };
@@ -76,12 +74,11 @@ ReturnedValue QmlListWrapper::create(QV8Engine *v8, QObject *object, int propId,
     return r.asReturnedValue();
 }
 
-ReturnedValue QmlListWrapper::create(QV8Engine *v8, const QQmlListProperty<QObject> &prop, int propType)
+ReturnedValue QmlListWrapper::create(ExecutionEngine *engine, const QQmlListProperty<QObject> &prop, int propType)
 {
-    ExecutionEngine *v4 = QV8Engine::getV4(v8);
-    Scope scope(v4);
+    Scope scope(engine);
 
-    Scoped<QmlListWrapper> r(scope, v4->memoryManager->alloc<QmlListWrapper>(v8));
+    Scoped<QmlListWrapper> r(scope, engine->memoryManager->alloc<QmlListWrapper>(engine));
     r->d()->object = prop.object;
     r->d()->property = prop;
     r->d()->propertyType = propType;
@@ -93,7 +90,7 @@ QVariant QmlListWrapper::toVariant() const
     if (!d()->object)
         return QVariant();
 
-    return QVariant::fromValue(QQmlListReferencePrivate::init(d()->property, d()->propertyType, d()->v8->engine()));
+    return QVariant::fromValue(QQmlListReferencePrivate::init(d()->property, d()->propertyType, d()->internalClass->engine->v8Engine->engine()));
 }
 
 
index 1345365..1c2ad03 100644 (file)
@@ -62,9 +62,8 @@ namespace QV4 {
 namespace Heap {
 
 struct QmlListWrapper : Object {
-    QmlListWrapper(QV8Engine *engine);
+    QmlListWrapper(ExecutionEngine *engine);
     ~QmlListWrapper();
-    QV8Engine *v8;
     QPointer<QObject> object;
     QQmlListProperty<QObject> property;
     int propertyType;
@@ -77,8 +76,8 @@ struct Q_QML_EXPORT QmlListWrapper : Object
     V4_OBJECT2(QmlListWrapper, Object)
     V4_NEEDS_DESTROY
 
-    static ReturnedValue create(QV8Engine *v8, QObject *object, int propId, int propType);
-    static ReturnedValue create(QV8Engine *v8, const QQmlListProperty<QObject> &prop, int propType);
+    static ReturnedValue create(ExecutionEngine *engine, QObject *object, int propId, int propType);
+    static ReturnedValue create(ExecutionEngine *engine, const QQmlListProperty<QObject> &prop, int propType);
 
     QVariant toVariant() const;
 
index e779c09..cf66c5c 100644 (file)
@@ -421,7 +421,7 @@ QV4::ReturnedValue QV8Engine::fromVariant(const QVariant &variant)
             typedef QQmlListReferencePrivate QDLRP;
             QDLRP *p = QDLRP::get((QQmlListReference*)ptr);
             if (p->object) {
-                return QV4::QmlListWrapper::create(this, p->property, p->propertyType);
+                return QV4::QmlListWrapper::create(scope.engine, p->property, p->propertyType);
             } else {
                 return QV4::Encode::null();
             }