diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2017-06-23 13:36:13 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-08-02 16:32:49 +0000 |
commit | c6b2dd879d02b21b18f80faab541f8f04286685a (patch) | |
tree | cfae0855871c1fa2cd2fcdf21b14af0a392ced93 /src/qml/jsapi | |
parent | db1034d093d76b4b6e66fcdd178800e0cf9d1005 (diff) |
Move property cache from the engine to QQmlType
Now that the property cache is independent of a specific
engine, we can cache them in QQmlType instead of caching
them per engine.
This simplifies the logic and avoids duplicated property
caches when multiple engines are running.
Task-number: QTBUG-61536
Change-Id: I6f082e1e7495ae0f5b92559e8d0a3437c56e303a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/jsapi')
-rw-r--r-- | src/qml/jsapi/qjsengine.cpp | 19 | ||||
-rw-r--r-- | src/qml/jsapi/qjsengine_p.h | 17 |
2 files changed, 4 insertions, 32 deletions
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index 17f3fcedae..35b4929c3a 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -730,10 +730,7 @@ QJSEnginePrivate *QJSEnginePrivate::get(QV4::ExecutionEngine *e) QJSEnginePrivate::~QJSEnginePrivate() { - typedef QHash<const QMetaObject *, QQmlPropertyCache *>::Iterator PropertyCacheIt; - - for (PropertyCacheIt iter = propertyCache.begin(), end = propertyCache.end(); iter != end; ++iter) - (*iter)->release(); + // ### FIXME: sweep unused QQmlType instances } void QJSEnginePrivate::addToDebugServer(QJSEngine *q) @@ -756,20 +753,6 @@ void QJSEnginePrivate::removeFromDebugServer(QJSEngine *q) server->removeEngine(q); } -QQmlPropertyCache *QJSEnginePrivate::createCache(const QMetaObject *mo) -{ - if (!mo->superClass()) { - QQmlPropertyCache *rv = new QQmlPropertyCache(mo); - propertyCache.insert(mo, rv); - return rv; - } else { - QQmlPropertyCache *super = cache(mo->superClass()); - QQmlPropertyCache *rv = super->copyAndAppend(mo); - propertyCache.insert(mo, rv); - return rv; - } -} - /*! \since 5.5 \relates QJSEngine diff --git a/src/qml/jsapi/qjsengine_p.h b/src/qml/jsapi/qjsengine_p.h index 2b462451ed..cbfe0f14a3 100644 --- a/src/qml/jsapi/qjsengine_p.h +++ b/src/qml/jsapi/qjsengine_p.h @@ -55,6 +55,7 @@ #include <QtCore/qmutex.h> #include "qjsengine.h" #include "private/qtqmlglobal_p.h" +#include <private/qqmlmetatype_p.h> QT_BEGIN_NAMESPACE @@ -110,14 +111,6 @@ public: // These methods may be called from the QML loader thread inline QQmlPropertyCache *cache(QObject *obj); inline QQmlPropertyCache *cache(const QMetaObject *); - -private: - // Must be called locked - QQmlPropertyCache *createCache(const QMetaObject *); - - // These members must be protected by a QJSEnginePrivate::Locker as they are required by - // the threaded loader. Only access them through their respective accessor methods. - QHash<const QMetaObject *, QQmlPropertyCache *> propertyCache; }; QJSEnginePrivate::Locker::Locker(const QJSEngine *e) @@ -174,9 +167,7 @@ QQmlPropertyCache *QJSEnginePrivate::cache(QObject *obj) Locker locker(this); const QMetaObject *mo = obj->metaObject(); - QQmlPropertyCache *rv = propertyCache.value(mo); - if (!rv) rv = createCache(mo); - return rv; + return QQmlMetaType::propertyCache(mo); } /*! @@ -193,9 +184,7 @@ QQmlPropertyCache *QJSEnginePrivate::cache(const QMetaObject *metaObject) Q_ASSERT(metaObject); Locker locker(this); - QQmlPropertyCache *rv = propertyCache.value(metaObject); - if (!rv) rv = createCache(metaObject); - return rv; + return QQmlMetaType::propertyCache(metaObject); } |