aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlmetatype.cpp29
-rw-r--r--src/qml/qml/qqmlmetatype_p.h3
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h2
3 files changed, 34 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 3e29222200..a2b6913943 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -110,6 +110,9 @@ struct QQmlMetaTypeData
QString typeRegistrationNamespace;
QStringList typeRegistrationFailures;
+
+ QHash<const QMetaObject *, QQmlPropertyCache *> propertyCaches;
+ QQmlPropertyCache *propertyCache(const QMetaObject *metaObject);
};
class QQmlTypeModulePrivate
@@ -151,6 +154,9 @@ QQmlMetaTypeData::~QQmlMetaTypeData()
for (TypeModules::const_iterator i = uriToModule.constBegin(), cend = uriToModule.constEnd(); i != cend; ++i)
delete *i;
+ for (QHash<const QMetaObject *, QQmlPropertyCache *>::Iterator it = propertyCaches.begin(), end = propertyCaches.end();
+ it != end; ++it)
+ (*it)->release();
}
class QQmlTypePrivate
@@ -1981,6 +1987,29 @@ QQmlType QQmlMetaType::qmlTypeFromIndex(int idx)
return data->types.at(idx);
}
+QQmlPropertyCache *QQmlMetaTypeData::propertyCache(const QMetaObject *metaObject)
+{
+ if (QQmlPropertyCache *rv = propertyCaches.value(metaObject))
+ return rv;
+
+ if (!metaObject->superClass()) {
+ QQmlPropertyCache *rv = new QQmlPropertyCache(metaObject);
+ propertyCaches.insert(metaObject, rv);
+ return rv;
+ }
+ QQmlPropertyCache *super = propertyCache(metaObject->superClass());
+ QQmlPropertyCache *rv = super->copyAndAppend(metaObject);
+ propertyCaches.insert(metaObject, rv);
+ return rv;
+}
+
+QQmlPropertyCache *QQmlMetaType::propertyCache(const QMetaObject *metaObject)
+{
+ QMutexLocker lock(metaTypeDataLock());
+ QQmlMetaTypeData *data = metaTypeData();
+ return data->propertyCache(metaObject);
+}
+
/*!
Returns the list of registered QML type names.
*/
diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h
index d17172a917..c577a9cc18 100644
--- a/src/qml/qml/qqmlmetatype_p.h
+++ b/src/qml/qml/qqmlmetatype_p.h
@@ -70,6 +70,7 @@ class QQmlTypeModule;
class QHashedString;
class QHashedStringRef;
class QMutex;
+class QQmlPropertyCache;
namespace QV4 { struct String; }
@@ -89,6 +90,8 @@ public:
static QQmlType qmlType(const QUrl &url, bool includeNonFileImports = false);
static QQmlType qmlTypeFromIndex(int);
+ static QQmlPropertyCache *propertyCache(const QMetaObject *metaObject);
+
static QMetaProperty defaultProperty(const QMetaObject *);
static QMetaProperty defaultProperty(QObject *);
static QMetaMethod defaultMethod(const QMetaObject *);
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index 6444d8800a..8fdc95af3a 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -511,6 +511,8 @@ private:
QByteArray _checksum;
};
+typedef QQmlRefPointer<QQmlPropertyCache> QQmlPropertyCachePtr;
+
// QQmlMetaObject serves as a wrapper around either QMetaObject or QQmlPropertyCache.
// This is necessary as we delay creation of QMetaObject for synthesized QObjects, but
// we don't want to needlessly generate QQmlPropertyCaches every time we encounter a