diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2024-02-01 16:14:47 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2024-02-08 00:18:08 +0100 |
commit | 0af12845a4ae16fecb5107ca73ab046ea5fa5693 (patch) | |
tree | cc61c9420bc58399adfd72e227fdb3f4caaa5c37 /src/qml | |
parent | 2c6383bd8d907cbcc631e651fdb4d7aa1a3c75e0 (diff) |
QtQml: Do not speculatively create ICs for non-composite types
This just clobbers the type registry with useless trash.
Pick-to: 6.7 6.6
Task-number: QTBUG-120506
Change-Id: I9c56930493cfbe343359f6cb22eac2a6c76d01a2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/qml/qqmlimport.cpp | 10 | ||||
-rw-r--r-- | src/qml/qml/qqmlmetatype.cpp | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmlmetatype_p.h | 10 | ||||
-rw-r--r-- | src/qml/qml/qqmlpropertycachecreator_p.h | 8 |
4 files changed, 15 insertions, 16 deletions
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 2e482c220d..8a2d102e41 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -582,7 +582,7 @@ bool QQmlImportInstance::resolveType(QQmlTypeLoader *typeLoader, const QHashedSt bool ret = uri == typeStr; if (ret) { Q_ASSERT(!type_return->isValid()); - *type_return = QQmlMetaType::inlineComponentTypeForUrl(QUrl(url)); + *type_return = QQmlMetaType::fetchOrCreateInlineComponentTypeForUrl(QUrl(url)); } return ret; } @@ -745,8 +745,8 @@ bool QQmlImports::resolveType( } else { if (resolveTypeInNamespace(splitName.at(0), &m_unqualifiedset, nullptr)) { // either simple type + inline component - *type_return = QQmlMetaType::inlineComponentTypeForUrl( - type_return->sourceUrl(), splitName.at(1).toString()); + *type_return = QQmlMetaType::inlineComponentType( + *type_return, splitName.at(1).toString()); return true; } else { // or a failure @@ -767,8 +767,8 @@ bool QQmlImports::resolveType( error.setDescription(QQmlImportDatabase::tr("- %1 is not a namespace").arg(splitName.at(0).toString())); } else { if (resolveTypeInNamespace(splitName.at(1), s, nullptr)) { - *type_return = QQmlMetaType::inlineComponentTypeForUrl( - type_return->sourceUrl(), splitName.at(2).toString()); + *type_return = QQmlMetaType::inlineComponentType( + *type_return, splitName.at(2).toString()); return true; } else { error.setDescription(QQmlImportDatabase::tr("- %1 is not a type").arg(splitName.at(1).toString())); diff --git a/src/qml/qml/qqmlmetatype.cpp b/src/qml/qml/qqmlmetatype.cpp index 66f77edb39..10bb54fca8 100644 --- a/src/qml/qml/qqmlmetatype.cpp +++ b/src/qml/qml/qqmlmetatype.cpp @@ -1360,7 +1360,7 @@ QQmlType QQmlMetaType::qmlType(const QUrl &unNormalizedUrl, bool includeNonFileI return QQmlType(); } -QQmlType QQmlMetaType::inlineComponentTypeForUrl(const QUrl &url) +QQmlType QQmlMetaType::fetchOrCreateInlineComponentTypeForUrl(const QUrl &url) { QQmlMetaTypeDataPtr data; const auto it = data->inlineComponentTypes.constFind(url); @@ -1370,7 +1370,6 @@ QQmlType QQmlMetaType::inlineComponentTypeForUrl(const QUrl &url) return doRegisterInlineComponentType(data, url); } - /*! Returns a QQmlPropertyCache for \a obj if one is available. diff --git a/src/qml/qml/qqmlmetatype_p.h b/src/qml/qml/qqmlmetatype_p.h index bb592dfa07..3c2b893499 100644 --- a/src/qml/qml/qqmlmetatype_p.h +++ b/src/qml/qml/qqmlmetatype_p.h @@ -101,10 +101,14 @@ public: static QQmlType typeForUrl(const QString &urlString, const QHashedStringRef& typeName, CompositeTypeLookupMode mode, QList<QQmlError> *errors, QTypeRevision version = QTypeRevision()); - static QQmlType inlineComponentTypeForUrl(const QUrl &url); - static QQmlType inlineComponentTypeForUrl(const QUrl &baseUrl, const QString &name) + + static QQmlType fetchOrCreateInlineComponentTypeForUrl(const QUrl &url); + static QQmlType inlineComponentType(const QQmlType &outerType, const QString &name) { - return inlineComponentTypeForUrl(inlineComponentUrl(baseUrl, name)); + return outerType.isComposite() + ? fetchOrCreateInlineComponentTypeForUrl( + inlineComponentUrl(outerType.sourceUrl(), name)) + : QQmlType(); } static void unregisterType(int type); diff --git a/src/qml/qml/qqmlpropertycachecreator_p.h b/src/qml/qml/qqmlpropertycachecreator_p.h index fe0cdb5cd4..1067dd4c22 100644 --- a/src/qml/qml/qqmlpropertycachecreator_p.h +++ b/src/qml/qml/qqmlpropertycachecreator_p.h @@ -674,15 +674,11 @@ inline QQmlError QQmlPropertyCacheCreator<ObjectContainer>::createMetaObject( } // inline components are not necessarily valid yet - Q_ASSERT(qmltype.isValid() || qmltype.isInlineComponentType()); + Q_ASSERT(qmltype.isValid()); if (qmltype.isComposite() || qmltype.isInlineComponentType()) { QQmlType compositeType; if (qmltype.isInlineComponentType()) { - const QString icName = qmltype.elementName(); - compositeType = QQmlMetaType::inlineComponentTypeForUrl( - qmltype.sourceUrl(), icName); - if (!compositeType.isValid()) // type has not been registered yet, we must be in containing type - compositeType = objectContainer->qmlTypeForComponent(icName); + compositeType = qmltype; Q_ASSERT(compositeType.isValid()); } else if (selfReference) { compositeType = objectContainer->qmlTypeForComponent(); |