diff options
author | Thomas Hartmann <Thomas.Hartmann@digia.com> | 2012-10-22 14:16:30 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-23 11:55:36 +0200 |
commit | 85fd1c48f32c266168c2e3d8195f81e59a7dc5e6 (patch) | |
tree | 6319451fa2c41a8cfffb26569e4a18d07c2abe70 /src | |
parent | 29bfe1db8a5b4480317701ae508f0c920c925525 (diff) |
Adding invalidate function to QQmlPropertyCache
This is required for tooling to update a QMetaObject
inside a running QQmlEngine.
Change-Id: I26d3aeed57d39c361c150261c4e1a84094e6f657
Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/qqmlpropertycache.cpp | 33 | ||||
-rw-r--r-- | src/qml/qml/qqmlpropertycache_p.h | 1 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp index 431a5be01b..c1c4a6c03d 100644 --- a/src/qml/qml/qqmlpropertycache.cpp +++ b/src/qml/qml/qqmlpropertycache.cpp @@ -849,6 +849,39 @@ void QQmlPropertyCache::update(QQmlEngine *engine, const QMetaObject *metaObject } /*! \internal + invalidates and updates the PropertyCache if the QMetaObject has changed. + This function is used in the tooling to update dynamic properties. +*/ +void QQmlPropertyCache::invalidate(QQmlEngine *engine, const QMetaObject *metaObject) +{ + stringCache.clear(); + propertyIndexCache.clear(); + methodIndexCache.clear(); + signalHandlerIndexCache.clear(); + + _hasPropertyOverrides = false; + argumentsCache = 0; + + int pc = metaObject->propertyCount(); + int mc = metaObject->methodCount(); + int sc = metaObjectSignalCount(metaObject); + int reserve = pc + mc + sc; + + if (parent()) { + propertyIndexCacheStart = parent()->propertyIndexCache.count() + parent()->propertyIndexCacheStart; + methodIndexCacheStart = parent()->methodIndexCache.count() + parent()->methodIndexCacheStart; + signalHandlerIndexCacheStart = parent()->signalHandlerIndexCache.count() + parent()->signalHandlerIndexCacheStart; + stringCache.linkAndReserve(parent()->stringCache, reserve); + append(engine, metaObject, -1); + } else { + propertyIndexCacheStart = 0; + methodIndexCacheStart = 0; + signalHandlerIndexCacheStart = 0; + update(engine, metaObject); + } +} + +/*! \internal \a index MUST be in the signal index range (see QObjectPrivate::signalIndex()). This is different from QMetaMethod::methodIndex(). */ diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h index 4310e4ea40..14be99045f 100644 --- a/src/qml/qml/qqmlpropertycache_p.h +++ b/src/qml/qml/qqmlpropertycache_p.h @@ -247,6 +247,7 @@ public: virtual ~QQmlPropertyCache(); void update(QQmlEngine *, const QMetaObject *); + void invalidate(QQmlEngine *, const QMetaObject *); QQmlPropertyCache *copy(); |