diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-07-25 15:47:40 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-25 07:49:00 +0200 |
commit | c500bd41751ca253fe40868fe54557749736d109 (patch) | |
tree | d9ef36ad77ea32176388dc0de5aab8a71b50e14f /src/declarative/qml | |
parent | 5249c88dfd0ddb19c8b608a895b0b0b676aff27e (diff) |
Allow object to be accessed by multiple QDeclarativeEngines
Task-number: QTBUG-18610
Change-Id: Idd9444018b5344586d6579ddac6a0ffd26bf7139
Reviewed-on: http://codereview.qt.nokia.com/2075
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qdeclarativepropertycache.cpp | 22 | ||||
-rw-r--r-- | src/declarative/qml/v8/qv8qobjectwrapper.cpp | 2 |
2 files changed, 10 insertions, 14 deletions
diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp index 8dba8e4350..6ff47d7b57 100644 --- a/src/declarative/qml/qdeclarativepropertycache.cpp +++ b/src/declarative/qml/qdeclarativepropertycache.cpp @@ -220,20 +220,17 @@ QDeclarativePropertyCache::QDeclarativePropertyCache(QDeclarativeEngine *e, cons QDeclarativePropertyCache::~QDeclarativePropertyCache() { clear(); -} -void QDeclarativePropertyCache::clear() -{ if (parent) parent->release(); parent = 0; +} - propertyIndexCacheStart = 0; - methodIndexCacheStart = 0; - - propertyIndexCache.clear(); - methodIndexCache.clear(); - stringCache.clear(); +// This is inherited from QDeclarativeCleanup, so it should only clear the things +// that are tied to the specific QDeclarativeEngine. +void QDeclarativePropertyCache::clear() +{ qPersistentDispose(constructor); + engine = 0; } QDeclarativePropertyCache::Data QDeclarativePropertyCache::create(const QMetaObject *metaObject, @@ -417,8 +414,7 @@ void QDeclarativePropertyCache::update(QDeclarativeEngine *engine, const QMetaOb { Q_ASSERT(engine); Q_ASSERT(metaObject); - - clear(); + Q_ASSERT(stringCache.isEmpty()); // Optimization to prevent unnecessary reallocation of lists propertyIndexCache.reserve(metaObject->propertyCount()); @@ -508,7 +504,7 @@ QDeclarativePropertyCache::property(QDeclarativeEngine *engine, QObject *obj, QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); QDeclarativeData *ddata = QDeclarativeData::get(obj); - if (ddata && ddata->propertyCache && ddata->propertyCache->qmlEngine() == engine) // XXX aakenend + if (ddata && ddata->propertyCache) cache = ddata->propertyCache; if (!cache) { cache = ep->cache(obj); @@ -546,7 +542,7 @@ QDeclarativePropertyCache::property(QDeclarativeEngine *engine, QObject *obj, QDeclarativePropertyCache *cache = 0; QDeclarativeData *ddata = QDeclarativeData::get(obj); - if (ddata && ddata->propertyCache && ddata->propertyCache->qmlEngine() == engine) + if (ddata && ddata->propertyCache) cache = ddata->propertyCache; if (!cache) { cache = enginePrivate->cache(obj); diff --git a/src/declarative/qml/v8/qv8qobjectwrapper.cpp b/src/declarative/qml/v8/qv8qobjectwrapper.cpp index f10c49a06d..393f8376f1 100644 --- a/src/declarative/qml/v8/qv8qobjectwrapper.cpp +++ b/src/declarative/qml/v8/qv8qobjectwrapper.cpp @@ -878,7 +878,7 @@ v8::Local<v8::Object> QV8QObjectWrapper::newQObject(QObject *object, QDeclarativ if (ddata->propertyCache) ddata->propertyCache->addref(); } - if (ddata->propertyCache) { + if (ddata->propertyCache && ddata->propertyCache->qmlEngine() == engine->engine()) { rv = ddata->propertyCache->newQObject(object, engine); } else { // XXX NewInstance() should be optimized |