From 57ecb25593fb7dd6601e1718773ce52e4247b500 Mon Sep 17 00:00:00 2001 From: Andrei Golubev Date: Wed, 2 Jun 2021 10:07:25 +0200 Subject: Set index to QQmlJSMetaProperty when traversing QQmlJS::AST Along the way, add few Q_ASSERTs to make sure property index is set when it should be set Change-Id: Ifa2d3e08deda65368f47c7071385b0f24dd4cecd Reviewed-by: Ulf Hermann --- tools/qmllint/findwarnings.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tools') diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp index 31ecb9a03a..916962a12d 100644 --- a/tools/qmllint/findwarnings.cpp +++ b/tools/qmllint/findwarnings.cpp @@ -689,6 +689,15 @@ void FindWarningVisitor::endVisit(QQmlJS::AST::UiObjectDefinition *uiod) auto property = scope->property(parentPropertyName); property.setType(QQmlJSScope::ConstPtr(m_currentScope)); + if (childScope->hasOwnProperty(parentPropertyName)) { + Q_ASSERT(childScope->ownProperty(parentPropertyName).index() >= 0); + } else { + // it's a new property, so must adjust the index. the index is + // "outdated" as it's a relative index of scope, not childScope (or + // it might even be -1 in theory but this is likely an error) + property.setIndex(childScope->ownProperties().size()); + } + // TODO: This is bad. We shouldn't add a new property but rather amend the existing one. childScope->addOwnProperty(property); } -- cgit v1.2.3