diff options
author | Ulf Hermann <[email protected]> | 2025-01-15 14:34:59 +0100 |
---|---|---|
committer | Ulf Hermann <[email protected]> | 2025-01-16 20:31:06 +0100 |
commit | 4ae701226edbf17abb7a758e7fd3f97b6dd7a894 (patch) | |
tree | dacb63d03dd59f098966819dd818f073625f224f /src/plugins/qmllint/quick/quicklintplugin.cpp | |
parent | 7d455e32743f3c034c37d41c274e405917a7be53 (diff) |
QuickLintPlugin: Guard against deceptive default properties
If the default property has been overridden, we cannot say anything
about the children anymore.
Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-132805
Change-Id: I4d8990b43801976a86b1416f70ee517cda57bda9
Reviewed-by: Olivier De Cannière <[email protected]>
Reviewed-by: Fabian Kosmale <[email protected]>
Diffstat (limited to 'src/plugins/qmllint/quick/quicklintplugin.cpp')
-rw-r--r-- | src/plugins/qmllint/quick/quicklintplugin.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/plugins/qmllint/quick/quicklintplugin.cpp b/src/plugins/qmllint/quick/quicklintplugin.cpp index 0f78f0f4af..c40499e84f 100644 --- a/src/plugins/qmllint/quick/quicklintplugin.cpp +++ b/src/plugins/qmllint/quick/quicklintplugin.cpp @@ -50,6 +50,15 @@ void ForbiddenChildrenPropertyValidatorPass::run(const QQmlSA::Element &element) { for (const auto &elementPair : std::as_const(m_types).asKeyValueRange()) { const QQmlSA::Element &type = elementPair.first; + const QQmlSA::Element parentScope = element.parentScope(); + + // If the parent's default property is not what we think it is, then we can't say whether + // the element in question is actually a visual child of the (document) parent scope. + const QQmlSA::Property defaultProperty + = parentScope.property(parentScope.defaultPropertyName()); + if (defaultProperty != type.property(type.defaultPropertyName())) + continue; + if (!element.parentScope().inherits(type)) continue; |