Hold a pointer to the QV4::ExecutionEngine in the property cache
authorLars Knoll <lars.knoll@theqtcompany.com>
Tue, 11 Aug 2015 13:43:30 +0000 (15:43 +0200)
committerSimon Hausmann <simon.hausmann@theqtcompany.com>
Wed, 19 Aug 2015 11:38:31 +0000 (11:38 +0000)
This makes more sense than a pointer to the QQmlEngine.

Change-Id: Ic6037b0df63b6cf1585539bc3ac78822f0e69d02
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
src/qml/jsapi/qjsengine.cpp
src/qml/qml/qqmlopenmetaobject.cpp
src/qml/qml/qqmlpropertycache.cpp
src/qml/qml/qqmlpropertycache_p.h
src/qml/qml/qqmlvmemetaobject.cpp
src/qml/util/qqmladaptormodel.cpp
tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp

index d9615d496ff579ebaed9628839bae81899717c03..4910b6a1c6c1c7d2ced430902a24d976287eca1f 100644 (file)
@@ -580,7 +580,7 @@ QJSEnginePrivate::~QJSEnginePrivate()
 QQmlPropertyCache *QJSEnginePrivate::createCache(const QMetaObject *mo)
 {
     if (!mo->superClass()) {
-        QQmlPropertyCache *rv = new QQmlPropertyCache(q_func(), mo);
+        QQmlPropertyCache *rv = new QQmlPropertyCache(QV8Engine::getV4(q_func()), mo);
         propertyCache.insert(mo, rv);
         return rv;
     } else {
index 777bb0c5e1c094cb4f86984f86cc31e2d68ba95c..16138508dd82333ec927c8d6d5e3175bfe898503 100644 (file)
@@ -35,6 +35,7 @@
 #include <private/qqmlpropertycache_p.h>
 #include <private/qqmldata_p.h>
 #include <private/qmetaobjectbuilder_p.h>
+#include <private/qv8engine_p.h>
 #include <qqmlengine.h>
 #include <qdebug.h>
 
@@ -367,7 +368,7 @@ void QQmlOpenMetaObject::setCached(bool c)
     QQmlData *qmldata = QQmlData::get(d->object, true);
     if (d->cacheProperties) {
         if (!d->type->d->cache)
-            d->type->d->cache = new QQmlPropertyCache(d->type->d->engine, this);
+            d->type->d->cache = new QQmlPropertyCache(QV8Engine::getV4(d->type->d->engine), this);
         qmldata->propertyCache = d->type->d->cache;
         d->type->d->cache->addref();
     } else {
index cd8eb0d3e26fae2bd2654f0623f2663d578a06af..9a935ed55f2978661b3fafbc30949dd2e599f10d 100644 (file)
@@ -231,10 +231,10 @@ void QQmlPropertyData::lazyLoad(const QMetaMethod &m)
 /*!
 Creates a new empty QQmlPropertyCache.
 */
-QQmlPropertyCache::QQmlPropertyCache(QJSEngine *e)
-: engine(e), _parent(0), propertyIndexCacheStart(0), methodIndexCacheStart(0),
-  signalHandlerIndexCacheStart(0), _hasPropertyOverrides(false), _ownMetaObject(false),
-  _metaObject(0), argumentsCache(0)
+QQmlPropertyCache::QQmlPropertyCache(QV4::ExecutionEngine *e)
+    : engine(e), _parent(0), propertyIndexCacheStart(0), methodIndexCacheStart(0),
+      signalHandlerIndexCacheStart(0), _hasPropertyOverrides(false), _ownMetaObject(false),
+      _metaObject(0), argumentsCache(0)
 {
     Q_ASSERT(engine);
 }
@@ -242,10 +242,10 @@ QQmlPropertyCache::QQmlPropertyCache(QJSEngine *e)
 /*!
 Creates a new QQmlPropertyCache of \a metaObject.
 */
-QQmlPropertyCache::QQmlPropertyCache(QJSEngine *e, const QMetaObject *metaObject)
-: engine(e), _parent(0), propertyIndexCacheStart(0), methodIndexCacheStart(0),
-  signalHandlerIndexCacheStart(0), _hasPropertyOverrides(false), _ownMetaObject(false),
-  _metaObject(0), argumentsCache(0)
+QQmlPropertyCache::QQmlPropertyCache(QV4::ExecutionEngine *e, const QMetaObject *metaObject)
+    : engine(e), _parent(0), propertyIndexCacheStart(0), methodIndexCacheStart(0),
+      signalHandlerIndexCacheStart(0), _hasPropertyOverrides(false), _ownMetaObject(false),
+      _metaObject(0), argumentsCache(0)
 {
     Q_ASSERT(engine);
     Q_ASSERT(metaObject);
@@ -818,7 +818,7 @@ void QQmlPropertyCache::resolve(QQmlPropertyData *data) const
                 data->propType = registerResult == -1 ? QMetaType::UnknownType : registerResult;
             }
         }
-        data->flags |= flagsForPropertyType(data->propType, qobject_cast<QQmlEngine*>(engine));
+        data->flags |= flagsForPropertyType(data->propType, engine->qmlEngine());
     }
 
     data->flags &= ~QQmlPropertyData::NotFullyResolved;
@@ -1134,7 +1134,7 @@ QString QQmlPropertyCache::signalParameterStringForJS(int index, QString *errorS
     }
 
     QString error;
-    QString parameters = signalParameterStringForJS(QV8Engine::getV4(engine), parameterNameList, &error);
+    QString parameters = signalParameterStringForJS(engine, parameterNameList, &error);
 
     A *arguments = static_cast<A *>(signalData->arguments);
     arguments->signalParameterStringForJS = new QString(!error.isEmpty() ? error : parameters);
index 4d8c6dd9a56c06b100aaeb9e034e49fc55f11d26..4f203a837c763969a4deaa5634efe601bf4054af 100644 (file)
@@ -243,8 +243,8 @@ class QQmlPropertyCacheMethodArguments;
 class Q_QML_PRIVATE_EXPORT QQmlPropertyCache : public QQmlRefCount, public QQmlCleanup
 {
 public:
-    QQmlPropertyCache(QJSEngine *);
-    QQmlPropertyCache(QJSEngine *, const QMetaObject *);
+    QQmlPropertyCache(QV4::ExecutionEngine *);
+    QQmlPropertyCache(QV4::ExecutionEngine *, const QMetaObject *);
     virtual ~QQmlPropertyCache();
 
     void update(const QMetaObject *);
@@ -377,7 +377,7 @@ private:
         _hasPropertyOverrides |= isOverride;
     }
 
-    QJSEngine *engine;
+    QV4::ExecutionEngine *engine;
 
     QQmlPropertyCache *_parent;
     int propertyIndexCacheStart;
index 6021b1ae794d9a26674b8dacaec133a790d1ffdb..0085fdee0070a0314c618bea396cf56dc9646210 100644 (file)
@@ -89,7 +89,6 @@ class QQmlVMEMetaObjectEndpoint : public QQmlNotifierEndpoint
 {
 public:
     QQmlVMEMetaObjectEndpoint();
-    static void vmecallback(QQmlNotifierEndpoint *, void **);
     void tryConnect();
 
     QFlagPointer<QQmlVMEMetaObject> metaObject;
index 17f4ffd62b80a5a3d11682ad35fa61dafce76b34..f83798488ce9e718f1a9a93a39445f8549d3989d 100644 (file)
@@ -547,7 +547,7 @@ public:
 
         metaObject = builder.toMetaObject();
         *static_cast<QMetaObject *>(this) = *metaObject;
-        propertyCache = new QQmlPropertyCache(engine, metaObject);
+        propertyCache = new QQmlPropertyCache(QV8Engine::getV4(engine), metaObject);
     }
 };
 
index ce2aab49c317f85f71274090f000bf3a61f20c3a..a5ae27d446c8e0dc67c4d9b3ca644747469f8dee 100644 (file)
@@ -34,6 +34,7 @@
 #include <qtest.h>
 #include <private/qqmlpropertycache_p.h>
 #include <QtQml/qqmlengine.h>
+#include <private/qv8engine_p.h>
 #include "../../shared/util.h"
 
 class tst_qqmlpropertycache : public QObject
@@ -102,10 +103,11 @@ QQmlPropertyData *cacheProperty(QQmlPropertyCache *cache, const char *name)
 void tst_qqmlpropertycache::properties()
 {
     QQmlEngine engine;
+    QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine);
     DerivedObject object;
     const QMetaObject *metaObject = object.metaObject();
 
-    QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject));
+    QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(v4, metaObject));
     QQmlPropertyData *data;
 
     QVERIFY(data = cacheProperty(cache, "propertyA"));
@@ -124,10 +126,11 @@ void tst_qqmlpropertycache::properties()
 void tst_qqmlpropertycache::propertiesDerived()
 {
     QQmlEngine engine;
+    QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine);
     DerivedObject object;
     const QMetaObject *metaObject = object.metaObject();
 
-    QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject));
+    QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(v4, &BaseObject::staticMetaObject));
     QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copyAndAppend(object.metaObject()));
     QQmlPropertyData *data;
 
@@ -147,10 +150,11 @@ void tst_qqmlpropertycache::propertiesDerived()
 void tst_qqmlpropertycache::methods()
 {
     QQmlEngine engine;
+    QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine);
     DerivedObject object;
     const QMetaObject *metaObject = object.metaObject();
 
-    QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject));
+    QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(v4, metaObject));
     QQmlPropertyData *data;
 
     QVERIFY(data = cacheProperty(cache, "slotA"));
@@ -181,10 +185,11 @@ void tst_qqmlpropertycache::methods()
 void tst_qqmlpropertycache::methodsDerived()
 {
     QQmlEngine engine;
+    QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine);
     DerivedObject object;
     const QMetaObject *metaObject = object.metaObject();
 
-    QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject));
+    QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(v4, &BaseObject::staticMetaObject));
     QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copyAndAppend(object.metaObject()));
     QQmlPropertyData *data;
 
@@ -216,10 +221,11 @@ void tst_qqmlpropertycache::methodsDerived()
 void tst_qqmlpropertycache::signalHandlers()
 {
     QQmlEngine engine;
+    QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine);
     DerivedObject object;
     const QMetaObject *metaObject = object.metaObject();
 
-    QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(&engine, metaObject));
+    QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(v4, metaObject));
     QQmlPropertyData *data;
 
     QVERIFY(data = cacheProperty(cache, "onSignalA"));
@@ -244,10 +250,11 @@ void tst_qqmlpropertycache::signalHandlers()
 void tst_qqmlpropertycache::signalHandlersDerived()
 {
     QQmlEngine engine;
+    QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine);
     DerivedObject object;
     const QMetaObject *metaObject = object.metaObject();
 
-    QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&engine, &BaseObject::staticMetaObject));
+    QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(v4, &BaseObject::staticMetaObject));
     QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copyAndAppend(object.metaObject()));
     QQmlPropertyData *data;