diff options
author | Eike Ziller <eike.ziller@qt.io> | 2022-04-05 11:20:23 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2022-04-20 08:24:15 +0000 |
commit | fb1f19c7c1334ae1fabde3a29a8e31d32622636b (patch) | |
tree | 92d7a27b2b8db07dce4b2a4a50c9453513425e93 | |
parent | debd1b3d4b9fc272edac81b8243a21d20a12a25f (diff) |
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 <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r-- | src/plugins/qtsupport/exampleslistmodel.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index ebe547176e..841ecd318f 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -42,6 +42,7 @@ #include <qtsupport/qtversionmanager.h> #include <utils/algorithm.h> +#include <utils/filepath.h> #include <utils/fileutils.h> #include <utils/qtcassert.h> #include <utils/stringutils.h> @@ -50,6 +51,8 @@ #include <algorithm> #include <memory> +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(); |