diff options
author | Vladimir Belyavsky <belyavskyv@gmail.com> | 2024-04-20 19:47:18 +0300 |
---|---|---|
committer | Vladimir Belyavsky <belyavskyv@gmail.com> | 2024-04-22 08:06:28 +0000 |
commit | 1c629c1a7f6f5f108989eec6cca7c0c814587232 (patch) | |
tree | ba5b4edc5a120a7052c3b9de566f1c55f750e78b | |
parent | 6f3ab82691d0f96ea83d2711c284cb4f451cf047 (diff) |
QuickLintPlugin: avoid detach with QHash::asKeyValueRange()
Wrap containers to std::as_const() before using non-const QHash::asKeyValueRange() in range-based for loop to avoid
unexpected detach.
Change-Id: Ie7317ebaeb91acb46393f84b2fc17176766d60a5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | src/plugins/qmllint/quick/quicklintplugin.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/plugins/qmllint/quick/quicklintplugin.cpp b/src/plugins/qmllint/quick/quicklintplugin.cpp index 0a5eb1d6b9..15b947a10c 100644 --- a/src/plugins/qmllint/quick/quicklintplugin.cpp +++ b/src/plugins/qmllint/quick/quicklintplugin.cpp @@ -37,7 +37,7 @@ bool ForbiddenChildrenPropertyValidatorPass::shouldRun(const QQmlSA::Element &el if (!element.parentScope()) return false; - for (const auto &pair : m_types.asKeyValueRange()) { + for (const auto &pair : std::as_const(m_types).asKeyValueRange()) { if (element.parentScope().inherits(pair.first)) return true; } @@ -47,7 +47,7 @@ bool ForbiddenChildrenPropertyValidatorPass::shouldRun(const QQmlSA::Element &el void ForbiddenChildrenPropertyValidatorPass::run(const QQmlSA::Element &element) { - for (const auto &elementPair : m_types.asKeyValueRange()) { + for (const auto &elementPair : std::as_const(m_types).asKeyValueRange()) { const QQmlSA::Element &type = elementPair.first; if (!element.parentScope().inherits(type)) continue; @@ -434,7 +434,7 @@ VarBindingTypeValidatorPass::VarBindingTypeValidatorPass( { QMultiHash<QString, QQmlSA::Element> propertyTypes; - for (const auto pair : expectedPropertyTypes.asKeyValueRange()) { + for (const auto &pair : expectedPropertyTypes.asKeyValueRange()) { const QQmlSA::Element propType = pair.second.module.isEmpty() ? resolveBuiltinType(pair.second.name) : resolveType(pair.second.module, pair.second.name); |