Skip to content

Commit f81f6f0

Browse files
authored
Fix #14829 (GUI: Platform configuration mismatch between UI selection and analysis log) (cppcheck-opensource#8833)
1 parent b9d85e1 commit f81f6f0

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

‎gui/mainwindow.cpp‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ static QString fromNativePath(const QString& p) {
118118
#endif
119119
}
120120

121+
template<typename T = std::vector<std::string>>
122+
static T toStdStringList(const QStringList& stringList) {
123+
T ret;
124+
std::transform(stringList.cbegin(), stringList.cend(), std::back_inserter(ret), [](const QString& s) {
125+
return s.toStdString();
126+
});
127+
return ret;
128+
}
129+
121130
MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
122131
mSettings(settings),
123132
mApplications(new ApplicationList(this)),
@@ -584,7 +593,7 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLib, const bo
584593
});
585594
p.ignorePaths(v);
586595

587-
if (!mProjectFile->getAnalyzeAllVsConfigs()) {
596+
if (checkSettings.platform.type == Platform::Native && !mProjectFile->getAnalyzeAllVsConfigs()) {
588597
const Platform::Type platform = static_cast<Platform::Type>(mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt());
589598
std::vector<std::string> configurations;
590599
const QStringList configs = mProjectFile->getVsConfigurations();
@@ -697,10 +706,7 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLib, c
697706

698707
if (!checkSettings.buildDir.empty()) {
699708
checkSettings.loadSummaries();
700-
std::list<std::string> sourcefiles;
701-
std::transform(fileNames.cbegin(), fileNames.cend(), std::back_inserter(sourcefiles), [](const QString& s) {
702-
return s.toStdString();
703-
});
709+
const auto& sourcefiles = toStdStringList<std::list<std::string>>(fileNames);
704710
AnalyzerInformation::writeFilesTxt(checkSettings.buildDir, sourcefiles, {});
705711
}
706712

@@ -1155,10 +1161,7 @@ bool MainWindow::getCppcheckSettings(Settings& settings, Suppressions& supprs)
11551161

11561162
const QString platform = mProjectFile->getPlatform();
11571163
if (platform.endsWith(".xml")) {
1158-
const std::vector<std::string> paths = {
1159-
Path::getCurrentPath(), // TODO: do we want to look in CWD?
1160-
QCoreApplication::applicationFilePath().toStdString(),
1161-
};
1164+
const std::vector<std::string> paths = toStdStringList(mProjectFile->getSearchPaths("platform"));
11621165
settings.platform.loadFromFile(paths, platform.toStdString());
11631166
} else {
11641167
for (int i = Platform::Type::Native; i <= Platform::Type::Unix64; i++) {

0 commit comments

Comments
 (0)