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:13 +0100 |
| commit | e516ef519b116f27d7ed5387275be27a4215a792 (patch) | |
| tree | f1267aa1ea0757de09a67ab878ae2b4527d078ff /src/qml/jsruntime/qv4function.cpp | |
| parent | 0af12845a4ae16fecb5107ca73ab046ea5fa5693 (diff) | |
QtQml: Double-check inline components when type-checking functions
Inline components are created speculatively. You can end up with a
QQmlType that's not backed by a compilation unit.
Pick-to: 6.7 6.6
Fixes: QTBUG-120506
Change-Id: Ie12f0d503ae8d8d238346948981803c1c07e8515
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4function.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4function.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp index 2e51366d64..a853eac41d 100644 --- a/src/qml/jsruntime/qv4function.cpp +++ b/src/qml/jsruntime/qv4function.cpp @@ -154,16 +154,23 @@ Function::Function(ExecutionEngine *engine, ExecutableCompilationUnit *unit, base->stringAt(type), typeLoader).type : QQmlType(); - if (!qmltype.isValid() || qmltype.typeId().isValid()) + if (!qmltype.isValid() || qmltype.isComposite()) return qmltype; - if (!qmltype.isComposite()) { - return qmltype.isInlineComponentType() - ? base->qmlTypeForComponent(qmltype.elementName()) - : QQmlType(); + if (qmltype.isInlineComponentType()) { + if (qmltype.typeId().isValid()) { + // If it seems to be an IC type, make sure there is an actual + // compilation unit for it. We create inline component types speculatively. + return QQmlMetaType::obtainCompilationUnit(qmltype.typeId()) + ? qmltype + : QQmlType(); + } else { + // TODO: Can this actually happen? + return base->qmlTypeForComponent(qmltype.elementName()); + } } - return qmltype; + return qmltype.typeId().isValid() ? qmltype : QQmlType(); }; for (quint16 i = 0; i < nFormals; ++i) |
