aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlmetatype.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-07-07 10:34:06 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-07-11 14:12:08 +0200
commit60322fc1ce65a6c7b425719bbc47418153175304 (patch)
tree99c419377c622b214934d96e003b2a29803b1343 /src/qml/qml/qqmlmetatype.cpp
parent20f608651b32bc8a8a7c5dbf6a079666e9de446c (diff)
QtQml: Slightly optimize QQmlType proxy creation methods
We don't need the metatype data pointer if we're not going to resolve any types. Also, add a comment regarding the questionable nature of the extension resolution algorithm. Change-Id: I90ba161caea51c5915b140d1029b2327fba80a3b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlmetatype.cpp')
-rw-r--r--src/qml/qml/qqmlmetatype.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp
index 9d217147e4..68df74a1a2 100644
--- a/src/qml/qml/qqmlmetatype.cpp
+++ b/src/qml/qml/qqmlmetatype.cpp
@@ -1752,7 +1752,8 @@ QList<QQmlProxyMetaObject::ProxyData> QQmlMetaType::proxyData(const QMetaObject
QList<QQmlProxyMetaObject::ProxyData> metaObjects;
mo = mo->d.superdata;
- const QQmlMetaTypeDataPtr data;
+ if (!mo)
+ return metaObjects;
auto createProxyMetaObject = [&](QQmlTypePrivate *This,
const QMetaObject *superdataBaseMetaObject,
@@ -1775,19 +1776,25 @@ QList<QQmlProxyMetaObject::ProxyData> QQmlMetaType::proxyData(const QMetaObject
registerMetaObjectForType(mmo, This);
};
- while (mo) {
- QQmlTypePrivate *t = data->metaObjectToType.value(mo);
- if (t) {
+ for (const QQmlMetaTypeDataPtr data; mo; mo = mo->d.superdata) {
+ // TODO: There can in fact be multiple QQmlTypePrivate* for a single QMetaObject*.
+ // This algorithm only accounts for the most recently inserted one. That's pretty
+ // random. However, the availability of types depends on what documents you have
+ // loaded before. Just adding all possible extensions would also be pretty random.
+ // The right way to do this would be to take the relations between the QML modules
+ // into account. For this we would need proper module dependency information.
+ if (QQmlTypePrivate *t = data->metaObjectToType.value(mo)) {
if (t->regType == QQmlType::CppType) {
- createProxyMetaObject(t, t->baseMetaObject, t->extraData.cppTypeData->extMetaObject,
- t->extraData.cppTypeData->extFunc);
+ createProxyMetaObject(
+ t, t->baseMetaObject, t->extraData.cppTypeData->extMetaObject,
+ t->extraData.cppTypeData->extFunc);
} else if (t->regType == QQmlType::SingletonType) {
- createProxyMetaObject(t, t->baseMetaObject, t->extraData.singletonTypeData->extMetaObject,
- t->extraData.singletonTypeData->extFunc);
+ createProxyMetaObject(
+ t, t->baseMetaObject, t->extraData.singletonTypeData->extMetaObject,
+ t->extraData.singletonTypeData->extFunc);
}
}
- mo = mo->d.superdata;
- }
+ };
return metaObjects;
}