diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2021-10-19 11:55:56 +0200 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2021-10-25 15:25:18 +0200 |
commit | a950f244673a8019a33088f81354a427bdd6712c (patch) | |
tree | 8867f509f67d7749381d49fe3907a5bfcecd5c0a /tools | |
parent | 068b0c5feb3562b46664246c926cbcaeff8154bc (diff) |
qmllint: Fix crash when no Connections parent can be found
When a Connections component is the root component, we are unable to find a parent component which used to lead to a crash.
This change fixes this issue. While this usage cannot be analyzed by qmllint at the moment it should at the very least not lead to a crash.
Fixes: QTBUG-97600
Change-Id: If831d9c5ec822693896d48d65689d12628a6690e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit b503914a53564557ae9b098a0106fbbe6c6a5031)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmllint/findwarnings.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp index e8871d673e..96821c5367 100644 --- a/tools/qmllint/findwarnings.cpp +++ b/tools/qmllint/findwarnings.cpp @@ -77,7 +77,10 @@ bool FindWarningVisitor::visit(QQmlJS::AST::UiObjectDefinition *uiod) // no target set, connection comes from parentF QQmlJSScope::Ptr scope = m_currentScope; do { - scope = scope->parentScope(); // TODO: rename method + if (auto parentScope = scope->parentScope(); !parentScope.isNull()) + scope = parentScope; + else + break; } while (scope->scopeType() != QQmlJSScope::QMLScope); targetScope = m_rootScopeImports.value(scope->baseTypeName()); } else { |