diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2021-09-15 14:29:16 +0200 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2021-09-21 10:57:24 +0200 |
commit | 64a3e205edfe0de8283bbc83d65ec808464d0ab5 (patch) | |
tree | e1ba8b26e2b4cb86d733acc931d95fefe3a14255 /src/qmlcompiler/qqmljsimportvisitor.cpp | |
parent | b7557eb8699311e733d08a380d8216a7159cc426 (diff) |
qmllint: Ignore scopes affected by inheritance cycles
We cannot reasonably process these because we will get caught up in endless loops when trying to check various things about them.
Fixes: QTBUG-96343
Change-Id: I866b26f008fd38f29f0875dc3138b000da16b264
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsimportvisitor.cpp')
-rw-r--r-- | src/qmlcompiler/qqmljsimportvisitor.cpp | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp index 7fa7ce115e..4535b0964d 100644 --- a/src/qmlcompiler/qqmljsimportvisitor.cpp +++ b/src/qmlcompiler/qqmljsimportvisitor.cpp @@ -322,6 +322,23 @@ bool QQmlJSImportVisitor::visit(QQmlJS::AST::UiProgram *) void QQmlJSImportVisitor::endVisit(UiProgram *) { + for (const auto &scope : m_objectBindingScopes) { + if (checkInheritanceCycle(scope) == CycleFound) + return; + } + + for (const auto &scope : m_objectDefinitionScopes) { + if (checkInheritanceCycle(scope) == CycleFound) + return; + + checkGroupedAndAttachedScopes(scope); + } + + for (const auto &scope : m_pendingDefaultProperties.keys()) { + if (checkInheritanceCycle(scope) == CycleFound) + return; + } + resolveAliases(); processDefaultProperties(); processPropertyTypes(); @@ -330,14 +347,6 @@ void QQmlJSImportVisitor::endVisit(UiProgram *) processPropertyBindingObjects(); checkRequiredProperties(); - for (const auto &scope : m_objectBindingScopes) - checkInheritanceCycle(scope); - - for (const auto &scope : m_objectDefinitionScopes) { - checkGroupedAndAttachedScopes(scope); - checkInheritanceCycle(scope); - } - auto unusedImports = m_importLocations; for (const QString &type : m_usedTypes) { for (const auto &importLocation : m_importTypeLocationMap.values(type)) @@ -826,7 +835,8 @@ void QQmlJSImportVisitor::addDefaultProperties() m_pendingDefaultProperties[m_currentScope->parentScope()] << m_currentScope; } -void QQmlJSImportVisitor::checkInheritanceCycle(QQmlJSScope::ConstPtr scope) +QQmlJSImportVisitor::HasCycle +QQmlJSImportVisitor::checkInheritanceCycle(QQmlJSScope::ConstPtr scope) { QQmlJSScope::ConstPtr originalScope = scope; QList<QQmlJSScope::ConstPtr> scopes; @@ -857,7 +867,7 @@ void QQmlJSImportVisitor::checkInheritanceCycle(QQmlJSScope::ConstPtr scope) .arg(scope->internalName()) .arg(inheritenceCycle), Log_InheritanceCycle); - break; + return CycleFound; } scopes.append(scope); @@ -874,6 +884,8 @@ void QQmlJSImportVisitor::checkInheritanceCycle(QQmlJSScope::ConstPtr scope) break; } } + + return CycleNotFound; } void QQmlJSImportVisitor::checkGroupedAndAttachedScopes(QQmlJSScope::ConstPtr scope) |