diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-10-16 09:17:42 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-10-19 09:30:13 +0200 |
commit | bf2258e6f44f1279eee5e9c2dd595c5dd2020784 (patch) | |
tree | ada16548f855b1b778bbfbb1ac1e09522c17e472 /src/qml | |
parent | bbeca33068718b8f5b820d20085e42ca86a5ffd5 (diff) |
QtQml: Don't unnecessarily detour through the CU to look up types
Since we also store partial types as QQmlType now, we can just look them
up the regular way.
Pick-to: 6.6 6.5 6.2
Fixes: QTBUG-117788
Change-Id: Id3e81853f802419f1121ef5e856c3272a3c977a1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/jsruntime/qv4function.cpp | 3 | ||||
-rw-r--r-- | src/qml/qml/qqml.cpp | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmlmetatype.cpp | 9 | ||||
-rw-r--r-- | src/qml/qml/qqmlpropertycachecreator_p.h | 19 |
4 files changed, 11 insertions, 26 deletions
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp index 44e05fbfcc..ced169407a 100644 --- a/src/qml/jsruntime/qv4function.cpp +++ b/src/qml/jsruntime/qv4function.cpp @@ -136,7 +136,6 @@ Function::Function(ExecutionEngine *engine, ExecutableCompilationUnit *unit, JSTypedFunction *synthesized = new JSTypedFunction; - QQmlEnginePrivate *enginePrivate = QQmlEnginePrivate::get(engine->qmlEngine()); auto findQmlType = [&](const CompiledData::ParameterType ¶m) { const quint32 type = param.typeNameIndexOrCommonType(); if (param.indexIsCommonType()) { @@ -158,7 +157,7 @@ Function::Function(ExecutionEngine *engine, ExecutableCompilationUnit *unit, : QQmlType(); } - return enginePrivate->typeLoader.getType(qmltype.sourceUrl())->compilationUnit()->qmlType; + return qmltype; }; for (quint16 i = 0; i < nFormals; ++i) diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp index d96a4d7d97..88e559f54f 100644 --- a/src/qml/qml/qqml.cpp +++ b/src/qml/qml/qqml.cpp @@ -1962,14 +1962,8 @@ bool AOTCompiledContext::loadTypeLookup(uint index, void *target) const const QV4::Heap::QQmlTypeWrapper *typeWrapper = static_cast<const QV4::Heap::QQmlTypeWrapper *>( l->qmlTypeLookup.qmlTypeWrapper); - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(qmlEngine()); QMetaType metaType = typeWrapper->type().typeId(); - if (!metaType.isValid()) { - metaType = ep->typeLoader.getType(typeWrapper->type().sourceUrl()) - ->compilationUnit()->qmlType.typeId(); - } - *static_cast<const QMetaObject **>(target) = QQmlMetaType::metaObjectForType(metaType).metaObject(); return true; diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index abd07611fb..10b69cf850 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -673,6 +673,8 @@ QQmlType QQmlMetaType::findCompositeType( } if (urlExists) { + if (compilationUnit.isNull()) + return QQmlType(*found); const auto composite = data->compositeTypes.constFind(found.value()->typeId.iface()); if (composite == data->compositeTypes.constEnd() || composite.value() == compilationUnit) return QQmlType(*found); @@ -1893,8 +1895,11 @@ void QQmlMetaType::registerInternalCompositeType( auto doInsert = [&data, &compilationUnit](const QtPrivate::QMetaTypeInterface *iface) { Q_ASSERT(iface); - const auto it = data->compositeTypes.constFind(iface); - Q_ASSERT(it == data->compositeTypes.constEnd() || *it == compilationUnit); + Q_ASSERT(compilationUnit); + + // We can't assert on anything else here. We may get a completely new type as exposed + // by the qmldiskcache test that changes a QML file in place during the execution + // of the test. data->compositeTypes.insert(iface, compilationUnit); }; diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h index 4d64ce6146..05e669a856 100644 --- a/src/qml/qml/qqmlpropertycachecreator_p.h +++ b/src/qml/qml/qqmlpropertycachecreator_p.h @@ -683,14 +683,9 @@ inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject( compositeType = objectContainer->qmlTypeForComponent(icName); Q_ASSERT(compositeType.isValid()); } else if (selfReference) { - compositeType = objectContainer->qmlTypeForComponent(); + compositeType = objectContainer->qmlTypeForComponent(); } else { - QQmlRefPointer<QQmlTypeData> tdata = enginePrivate->typeLoader.getType(qmltype.sourceUrl()); - Q_ASSERT(tdata); - Q_ASSERT(tdata->isComplete()); - - auto compilationUnit = tdata->compilationUnit(); - compositeType = compilationUnit->qmlTypeForComponent(); + compositeType = qmltype; } if (p->isList()) { @@ -766,15 +761,7 @@ inline QMetaType QQmlPropertyCacheCreator<ObjectContainer>::metaTypeForParameter return param.isList() ? qmlType.qListTypeId() : qmlType.typeId(); } - QQmlRefPointer<QQmlTypeData> tdata = enginePrivate->typeLoader.getType(qmltype.sourceUrl()); - Q_ASSERT(tdata); - Q_ASSERT(tdata->isComplete()); - - auto compilationUnit = tdata->compilationUnit(); - - return param.isList() - ? compilationUnit->qmlType.qListTypeId() - : compilationUnit->qmlType.typeId(); + return param.isList() ? qmltype.qListTypeId() : qmltype.typeId(); } template <typename ObjectContainer, typename CompiledObject> |