aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-03-16 15:07:04 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-03-17 09:05:09 +0100
commit1b5a6c19ab701c9b94b1ffb094999c34643bcd1d (patch)
tree02306d6a6f6e25ac73024f11f19edee2338483b0 /tools
parentebf6bf3b01f312fe066225c67f794f7ab67cb49a (diff)
qmllint: Don't crash on IDs that aren't scopes
In particular, those can be qualifiers for imports, in which case we have to combine them with the next segment in order to find the type. Task-number: QTBUG-82817 Change-Id: I217a79572cd1e160dcbbcb9541c53941c81ab76c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmllint/scopetree.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/tools/qmllint/scopetree.cpp b/tools/qmllint/scopetree.cpp
index 5c0fa526a4..07413094c0 100644
--- a/tools/qmllint/scopetree.cpp
+++ b/tools/qmllint/scopetree.cpp
@@ -293,9 +293,24 @@ bool ScopeTree::recheckIdentifiers(
auto it = qmlIDs.find(memberAccessTree->m_name);
if (it != qmlIDs.end()) {
- if (!checkMemberAccess(code, memberAccessTree.get(), *it, types, colorOut))
- noUnqualifiedIdentifier = false;
- continue;
+ if (*it != nullptr) {
+ if (!checkMemberAccess(code, memberAccessTree.get(), *it, types, colorOut))
+ noUnqualifiedIdentifier = false;
+ continue;
+ } else if (memberAccessTree->m_child
+ && memberAccessTree->m_child->m_name.front().isUpper()) {
+ // It could be a qualified type name
+ const QString qualified = memberAccessTree->m_name + QLatin1Char('.')
+ + memberAccessTree->m_child->m_name;
+ const auto typeIt = types.find(qualified);
+ if (typeIt != types.end()) {
+ if (!checkMemberAccess(code, memberAccessTree->m_child.get(), typeIt->get(),
+ types, colorOut)) {
+ noUnqualifiedIdentifier = false;
+ }
+ continue;
+ }
+ }
}
auto qmlScope = currentScope->currentQMLScope();