diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-12-03 01:11:42 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-01-18 12:51:38 +0100 |
commit | 5f76fabd0609f2a61b1ca53d88b6b76bb38e919a (patch) | |
tree | 604b1edcb9d690528a114c030cf8ddf5d93f746c /src/qml/qml/qqmlengine.cpp | |
parent | 26a97ace7cb9491a325f400b019d40f9413f0a68 (diff) |
Move propertyCache- and metaObject-related functions into QQmlMetaType
That's where the data resides. This allows us to lock the mutex only
once for all those methods, and it makes a large number of engine
pointers unnecessary.
Finally, we can now find the element type of a QQmlListProperty without
supplying an engine.
Change-Id: If1ae8eafe8762a112d1ca06f9c92ab8a727d1bda
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlengine.cpp')
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 8679e2a7b3..6f550ec725 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -1694,91 +1694,6 @@ QString QQmlEnginePrivate::offlineStorageDatabaseDirectory() const return q->offlineStoragePath() + QDir::separator() + QLatin1String("Databases") + QDir::separator(); } -/*! - * \internal - * - * Look up by type's baseMetaObject. - */ -QQmlMetaObject QQmlEnginePrivate::rawMetaObjectForType(QMetaType metaType) const -{ - if (auto composite = QQmlMetaType::findPropertyCacheInCompositeTypes(metaType)) - return QQmlMetaObject(composite); - - return QQmlMetaObject(QQmlMetaType::qmlType(metaType).baseMetaObject()); -} - -/*! - * \internal - * - * Look up by type's metaObject. - */ -QQmlMetaObject QQmlEnginePrivate::metaObjectForType(QMetaType metaType) const -{ - if (auto composite = QQmlMetaType::findPropertyCacheInCompositeTypes(metaType)) - return QQmlMetaObject(composite); - - return QQmlMetaObject(QQmlMetaType::qmlType(metaType).metaObject()); -} - -/*! - * \internal - * - * Look up by type's metaObject and version. - */ -QQmlRefPointer<QQmlPropertyCache> QQmlEnginePrivate::propertyCacheForType(QMetaType metaType) -{ - if (auto composite = QQmlMetaType::findPropertyCacheInCompositeTypes(metaType)) - return composite; - - const QQmlType type = QQmlMetaType::qmlType(metaType); - return type.isValid() - ? QQmlMetaType::propertyCache(type.metaObject(), type.version()) - : QQmlRefPointer<QQmlPropertyCache>(); -} - -/*! - * \internal - * - * Look up by type's baseMetaObject and unspecified/any version. - * TODO: Is this correct? Passing a plain QTypeRevision() rather than QTypeRevision::zero() or - * the actual type's version seems strange. The behavior has been in place for a while. - */ -QQmlRefPointer<QQmlPropertyCache> QQmlEnginePrivate::rawPropertyCacheForType(QMetaType metaType) -{ - if (auto composite = QQmlMetaType::findPropertyCacheInCompositeTypes(metaType)) - return composite; - - const QQmlType type = QQmlMetaType::qmlType(metaType); - return type.isValid() - ? QQmlMetaType::propertyCache(type.baseMetaObject(), QTypeRevision()) - : QQmlRefPointer<QQmlPropertyCache>(); -} - -/*! - * \internal - * - * Look up by QQmlType and version. We only fall back to lookup by metaobject if the type - * has no revisiononed attributes here. Unspecified versions are interpreted as "any". - */ -QQmlRefPointer<QQmlPropertyCache> QQmlEnginePrivate::rawPropertyCacheForType( - QMetaType metaType, QTypeRevision version) -{ - if (auto composite = QQmlMetaType::findPropertyCacheInCompositeTypes(metaType)) - return composite; - - const QQmlType type = QQmlMetaType::qmlType(metaType); - if (!type.isValid()) - return QQmlRefPointer<QQmlPropertyCache>(); - - if (type.containsRevisionedAttributes()) - return QQmlMetaType::propertyCache(type, version); - - if (const QMetaObject *metaObject = type.metaObject()) - return QQmlMetaType::propertyCache(metaObject, version); - - return QQmlRefPointer<QQmlPropertyCache>(); -} - template<> QJSValue QQmlEnginePrivate::singletonInstance<QJSValue>(const QQmlType &type) { |