From fb1f19c7c1334ae1fabde3a29a8e31d32622636b Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 5 Apr 2022 11:20:23 +0200 Subject: [PATCH] Fix duplicate entries in examples dropdown Both the "normal" Qt node adds an example set, and the Android/ Automotive node adds another one with the same paths, leading to e.g. two items "Qt6 6.2.4" in the dropdown for the examples. De-duplicate example sets with the same paths, which we already do if an example set and a Qt version itself refer to the same path. Fixes: QTCREATORBUG-27294 Change-Id: Ia469045b2f2812612fcd8328bdfd223479b8d449 Reviewed-by: Qt CI Bot Reviewed-by: Christian Stenger --- src/plugins/qtsupport/exampleslistmodel.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index ebe547176e2..841ecd318ff 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -50,6 +51,8 @@ #include #include +using namespace Utils; + namespace QtSupport { namespace Internal { @@ -101,12 +104,21 @@ ExampleSetModel::ExampleSetModel() qWarning() << "Manifest path " << set.manifestPath << "is not a readable directory, ignoring"; continue; } - m_extraExampleSets.append(set); if (debugExamples()) { qWarning() << "Adding examples set displayName=" << set.displayName << ", manifestPath=" << set.manifestPath << ", examplesPath=" << set.examplesPath; } + if (!Utils::anyOf(m_extraExampleSets, [&set](const ExtraExampleSet &s) { + return FilePath::fromString(s.examplesPath).cleanPath() + == FilePath::fromString(set.examplesPath).cleanPath() + && FilePath::fromString(s.manifestPath).cleanPath() + == FilePath::fromString(set.manifestPath).cleanPath(); + })) { + m_extraExampleSets.append(set); + } else if (debugExamples()) { + qWarning() << "Not adding, because example set with same directories exists"; + } } m_extraExampleSets += pluginRegisteredExampleSets();