aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2021-04-29 14:00:43 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2021-04-29 14:47:44 +0200
commitddb31fe22e5d61cf53f1865c5bfd0f981fd25f7d (patch)
tree551efdd66e89a65ff4421dcdb2372a158170c07c /tools
parent0e3902b83dc3c59567a81a90c3f3c0365bdf68da (diff)
qmllint: Do not choke on self attaching types
Previously qmllint would land in an endless loop when going over self-attaching types. This is now fixed and we also ensure that other cyclic type relationships can't cause the same issue. Change-Id: I788139a9632abe48c470f5f4e2dfb0cd96699d90 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmllint/checkidentifiers.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/qmllint/checkidentifiers.cpp b/tools/qmllint/checkidentifiers.cpp
index a22727492d..2c87023701 100644
--- a/tools/qmllint/checkidentifiers.cpp
+++ b/tools/qmllint/checkidentifiers.cpp
@@ -31,6 +31,7 @@
#include <QtQmlCompiler/private/qcoloroutput_p.h>
#include <QtCore/qqueue.h>
+#include <QtCore/private/qduplicatetracker_p.h>
#include <QtCore/qsharedpointer.h>
#include <stack>
@@ -46,12 +47,17 @@ static bool walkRelatedScopes(QQmlJSScope::ConstPtr rootType, const Visitor &vis
if (rootType.isNull())
return false;
std::stack<QQmlJSScope::ConstPtr> stack;
+ QDuplicateTracker<QQmlJSScope::ConstPtr> seenTypes;
stack.push(rootType);
while (!stack.empty()) {
const auto type = stack.top();
stack.pop();
+ // If we've seen this type before (can be caused by self attaching types), ignore it
+ if (seenTypes.hasSeen(type))
+ continue;
+
if (visit(type))
return true;