From 32988147b46e1d769b9e891472f0793536f9f3bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 13 Feb 2026 13:00:37 +0100 Subject: [PATCH 1/5] Fix #14489 (GUI: The platform files are not shown in the dropdown in ProjectFileDialog) --- gui/projectfile.cpp | 21 ++++++++++++++++++ gui/projectfile.h | 4 ++++ gui/projectfiledialog.cpp | 28 ++++-------------------- gui/test/projectfile/CMakeLists.txt | 1 + gui/test/projectfile/testprojectfile.cpp | 14 ++++++++++++ gui/test/projectfile/testprojectfile.h | 1 + gui/test/resultstree/CMakeLists.txt | 2 ++ gui/test/resultstree/testresultstree.cpp | 4 ---- 8 files changed, 47 insertions(+), 28 deletions(-) diff --git a/gui/projectfile.cpp b/gui/projectfile.cpp index 3e4e783d7a8..e3360002622 100644 --- a/gui/projectfile.cpp +++ b/gui/projectfile.cpp @@ -26,6 +26,7 @@ #include +#include #include #include #include @@ -1176,3 +1177,23 @@ QString ProjectFile::getAddonFilePath(QString filesDir, const QString &addon) return QString(); } + +QStringList ProjectFile::getSearchPaths(QString projectPath, QString appPath, QString datadir, QString dir) { + QStringList ret; + ret << appPath << (appPath + "/" + dir) << projectPath; +#ifdef FILESDIR + if (FILESDIR[0]) + ret << FILESDIR << (FILESDIR "/" + dir); +#endif + if (!datadir.isEmpty()) + ret << datadir << (datadir + "/" + dir); + return ret; +} + +QStringList ProjectFile::getSearchPaths(QString dir) const { + const QFileInfo inf(mFilename); + const QString applicationFilePath = QCoreApplication::applicationFilePath(); + const QString appPath = QFileInfo(applicationFilePath).canonicalPath(); + const QString datadir = getDataDir(); + return getSearchPaths(inf.canonicalFilePath(), appPath, datadir, dir); +} diff --git a/gui/projectfile.h b/gui/projectfile.h index 18503e8d6e1..8c021772a19 100644 --- a/gui/projectfile.h +++ b/gui/projectfile.h @@ -446,6 +446,10 @@ class ProjectFile : public QObject { /** Use Clang parser */ bool clangParser; + /** Get paths where we should glob for certain files (dir="cfg"/"platforms"/etc */ + QStringList getSearchPaths(QString dir) const; + static QStringList getSearchPaths(QString projectPath, QString appPath, QString datadir, QString dir); + protected: /** diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index eeee66231b7..4ea1569ec24 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -142,22 +141,10 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, bool premium, QWi mUI->premiumLicense->setVisible(false); - // Checkboxes for the libraries.. - const QString applicationFilePath = QCoreApplication::applicationFilePath(); - const QString appPath = QFileInfo(applicationFilePath).canonicalPath(); - const QString datadir = getDataDir(); - QStringList searchPaths; - searchPaths << appPath << appPath + "/cfg" << inf.canonicalPath(); -#ifdef FILESDIR - if (FILESDIR[0]) - searchPaths << FILESDIR << FILESDIR "/cfg"; -#endif - if (!datadir.isEmpty()) - searchPaths << datadir << datadir + "/cfg"; QStringList libs; // Search the std.cfg first since other libraries could depend on it QString stdLibraryFilename; - for (const QString &sp : searchPaths) { + for (const QString &sp : projectFile->getSearchPaths("cfg")) { QDir dir(sp); dir.setSorting(QDir::Name); dir.setNameFilters(QStringList("*.cfg")); @@ -179,7 +166,7 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, bool premium, QWi break; } // Search other libraries - for (const QString &sp : searchPaths) { + for (const QString &sp : projectFile->getSearchPaths("cfg")) { QDir dir(sp); dir.setSorting(QDir::Name); dir.setNameFilters(QStringList("*.cfg")); @@ -218,22 +205,15 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, bool premium, QWi for (const Platform::Type builtinPlatform : builtinPlatforms) mUI->mComboBoxPlatform->addItem(platforms.get(builtinPlatform).mTitle); QStringList platformFiles; - for (QString sp : searchPaths) { - if (sp.endsWith("/cfg")) - sp = sp.mid(0,sp.length()-3) + "platforms"; + for (QString sp : projectFile->getSearchPaths("platforms")) { QDir dir(sp); dir.setSorting(QDir::Name); dir.setNameFilters(QStringList("*.xml")); dir.setFilter(QDir::Files | QDir::NoDotAndDotDot); for (const QFileInfo& item : dir.entryInfoList()) { const QString platformFile = item.fileName(); - - const std::vector paths = { - Path::getCurrentPath(), // TODO: do we want to look in CWD? - applicationFilePath.toStdString(), - }; Platform plat2; - if (!plat2.loadFromFile(paths, platformFile.toStdString())) + if (!plat2.loadFromFile({sp.toStdString()}, platformFile.toStdString())) continue; if (platformFiles.indexOf(platformFile) == -1) diff --git a/gui/test/projectfile/CMakeLists.txt b/gui/test/projectfile/CMakeLists.txt index 2d9c254ec5f..f9bab8ba0c7 100644 --- a/gui/test/projectfile/CMakeLists.txt +++ b/gui/test/projectfile/CMakeLists.txt @@ -4,6 +4,7 @@ add_dependencies(gui-build-deps build-projectfile-deps) add_executable(test-projectfile ${test-projectfile_SRC} testprojectfile.cpp + ${CMAKE_SOURCE_DIR}/gui/common.cpp ${CMAKE_SOURCE_DIR}/gui/projectfile.cpp ) target_include_directories(test-projectfile PRIVATE ${CMAKE_SOURCE_DIR}/gui ${CMAKE_SOURCE_DIR}/lib) diff --git a/gui/test/projectfile/testprojectfile.cpp b/gui/test/projectfile/testprojectfile.cpp index 988d62e8bce..40b7b33b121 100644 --- a/gui/test/projectfile/testprojectfile.cpp +++ b/gui/test/projectfile/testprojectfile.cpp @@ -136,6 +136,20 @@ void TestProjectFile::getAddonFilePath() const QCOMPARE(ProjectFile::getAddonFilePath(tempdir.path(), filepath), filepath); } +void TestProjectFile::getSearchPaths() const +{ + QCOMPARE(ProjectFile::getSearchPaths("projectPath", "appPath", "datadir", "dir").join("\n"), + "appPath\n" + "appPath/dir\n" + "projectPath\n" +#ifdef FILESDIR + FILESDIR "\n" // example: "/usr/local/share/cppcheck\n" + FILESDIR "/dir\n" // example: "/usr/local/share/cppcheck/dir\n" +#endif + "datadir\n" + "datadir/dir"); +} + void TestProjectFile::getInlineSuppressionDefaultValue() const { ProjectFile projectFile; diff --git a/gui/test/projectfile/testprojectfile.h b/gui/test/projectfile/testprojectfile.h index 8f3e54c3008..027c7069706 100644 --- a/gui/test/projectfile/testprojectfile.h +++ b/gui/test/projectfile/testprojectfile.h @@ -28,6 +28,7 @@ private slots: void loadSimpleNoroot() const; void getAddonFilePath() const; + void getSearchPaths() const; void getInlineSuppressionDefaultValue() const; void getInlineSuppression() const; diff --git a/gui/test/resultstree/CMakeLists.txt b/gui/test/resultstree/CMakeLists.txt index 1bf8a02ffb1..a48b137e349 100644 --- a/gui/test/resultstree/CMakeLists.txt +++ b/gui/test/resultstree/CMakeLists.txt @@ -3,6 +3,7 @@ qt_wrap_cpp(test-resultstree_SRC ${CMAKE_SOURCE_DIR}/gui/resultstree.h ${CMAKE_SOURCE_DIR}/gui/resultitem.h ${CMAKE_SOURCE_DIR}/gui/applicationlist.h + ${CMAKE_SOURCE_DIR}/gui/common.h ${CMAKE_SOURCE_DIR}/gui/projectfile.h ${CMAKE_SOURCE_DIR}/gui/threadhandler.h ${CMAKE_SOURCE_DIR}/gui/threadresult.h @@ -14,6 +15,7 @@ add_executable(test-resultstree testresultstree.cpp ${CMAKE_SOURCE_DIR}/gui/resultstree.cpp ${CMAKE_SOURCE_DIR}/gui/resultitem.cpp + ${CMAKE_SOURCE_DIR}/gui/common.cpp ${CMAKE_SOURCE_DIR}/gui/erroritem.cpp ${CMAKE_SOURCE_DIR}/gui/showtypes.cpp ${CMAKE_SOURCE_DIR}/gui/report.cpp diff --git a/gui/test/resultstree/testresultstree.cpp b/gui/test/resultstree/testresultstree.cpp index ac3ba4ff78c..732ee0715d0 100644 --- a/gui/test/resultstree/testresultstree.cpp +++ b/gui/test/resultstree/testresultstree.cpp @@ -99,10 +99,6 @@ Application& ApplicationList::getApplication(const int /*unused*/) { const Application& ApplicationList::getApplication(const int index) const { return mApplications.at(index); } -QString getPath(const QString &type) { - return "/" + type; -} -void setPath(const QString & /*unused*/, const QString & /*unused*/) {} QString XmlReport::quoteMessage(const QString &message) { return message; } From 470ffeba87c42e293c6dc5013c63d632d5e9f2c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 13 Feb 2026 13:08:09 +0100 Subject: [PATCH 2/5] test --- gui/test/projectfile/testprojectfile.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gui/test/projectfile/testprojectfile.cpp b/gui/test/projectfile/testprojectfile.cpp index 40b7b33b121..b38de056ec3 100644 --- a/gui/test/projectfile/testprojectfile.cpp +++ b/gui/test/projectfile/testprojectfile.cpp @@ -138,14 +138,18 @@ void TestProjectFile::getAddonFilePath() const void TestProjectFile::getSearchPaths() const { +#ifdef FILESDIR + const QString f(FILESDIR "\n" // example: "/usr/local/share/cppcheck\n" + FILESDIR "/dir\n"); // example: "/usr/local/share/cppcheck/dir\n" +#else + const QString f; +#endif + QCOMPARE(ProjectFile::getSearchPaths("projectPath", "appPath", "datadir", "dir").join("\n"), "appPath\n" "appPath/dir\n" - "projectPath\n" -#ifdef FILESDIR - FILESDIR "\n" // example: "/usr/local/share/cppcheck\n" - FILESDIR "/dir\n" // example: "/usr/local/share/cppcheck/dir\n" -#endif + "projectPath\n" + + f + "datadir\n" "datadir/dir"); } From 56779e94238ab4612f53d6124c2d59f3dd0ef1c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 13 Feb 2026 17:31:58 +0100 Subject: [PATCH 3/5] selfcheck --- gui/projectfile.cpp | 4 ++-- gui/projectfile.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gui/projectfile.cpp b/gui/projectfile.cpp index e3360002622..d2913fbfd65 100644 --- a/gui/projectfile.cpp +++ b/gui/projectfile.cpp @@ -1178,7 +1178,7 @@ QString ProjectFile::getAddonFilePath(QString filesDir, const QString &addon) return QString(); } -QStringList ProjectFile::getSearchPaths(QString projectPath, QString appPath, QString datadir, QString dir) { +QStringList ProjectFile::getSearchPaths(const QString& projectPath, const QString& appPath, const QString& datadir, const QString& dir) { QStringList ret; ret << appPath << (appPath + "/" + dir) << projectPath; #ifdef FILESDIR @@ -1190,7 +1190,7 @@ QStringList ProjectFile::getSearchPaths(QString projectPath, QString appPath, QS return ret; } -QStringList ProjectFile::getSearchPaths(QString dir) const { +QStringList ProjectFile::getSearchPaths(const QString& dir) const { const QFileInfo inf(mFilename); const QString applicationFilePath = QCoreApplication::applicationFilePath(); const QString appPath = QFileInfo(applicationFilePath).canonicalPath(); diff --git a/gui/projectfile.h b/gui/projectfile.h index 8c021772a19..01abe0643a5 100644 --- a/gui/projectfile.h +++ b/gui/projectfile.h @@ -447,8 +447,8 @@ class ProjectFile : public QObject { bool clangParser; /** Get paths where we should glob for certain files (dir="cfg"/"platforms"/etc */ - QStringList getSearchPaths(QString dir) const; - static QStringList getSearchPaths(QString projectPath, QString appPath, QString datadir, QString dir); + QStringList getSearchPaths(const QString& dir) const; + static QStringList getSearchPaths(const QString& projectPath, const QString& appPath, const QString& datadir, const QString& dir); protected: From 1cd78269da7ae9558f2e1926e232156306b1621d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 14 Feb 2026 08:10:10 +0100 Subject: [PATCH 4/5] clang-tidy --- gui/projectfiledialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index 4ea1569ec24..76fe51d2274 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -205,7 +205,7 @@ ProjectFileDialog::ProjectFileDialog(ProjectFile *projectFile, bool premium, QWi for (const Platform::Type builtinPlatform : builtinPlatforms) mUI->mComboBoxPlatform->addItem(platforms.get(builtinPlatform).mTitle); QStringList platformFiles; - for (QString sp : projectFile->getSearchPaths("platforms")) { + for (const QString& sp : projectFile->getSearchPaths("platforms")) { QDir dir(sp); dir.setSorting(QDir::Name); dir.setNameFilters(QStringList("*.xml")); From 0d1dabc24ff117bcb405e8224dc82b7238c14c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 14 Feb 2026 12:40:24 +0100 Subject: [PATCH 5/5] manual test --- gui/manualtest/projectfiledialog.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gui/manualtest/projectfiledialog.md b/gui/manualtest/projectfiledialog.md index e8ce09cc96e..eb76109e53e 100644 --- a/gui/manualtest/projectfiledialog.md +++ b/gui/manualtest/projectfiledialog.md @@ -4,8 +4,21 @@ Some manual testing in the project file dialog interface + +## Test: Platform files + +Ticket: #14489 + +EXPECTED: In the project file dialog it should be possible to select xml files i.e. pic8.xml + +TODO: can this test be automated + + + ## Test: Misra C checkbox +Ticket: #14488 + Matrix: Use both open source and premium 1. Load project file in trac ticket 14488