diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 666d94ee1..1f6add593 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -498,7 +498,12 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons if (!mProjectFile->getAnalyzeAllVsConfigs()) { const cppcheck::Platform::Type platform = (cppcheck::Platform::Type) mSettings->value(SETTINGS_CHECKED_PLATFORM, 0).toInt(); - p.selectOneVsConfig(platform); + std::vector configurations; + const QStringList configs = mProjectFile->getVsConfigurations(); + std::transform(configs.cbegin(), configs.cend(), std::back_inserter(configurations), [](const QString& e) { + return e.toStdString(); + }); + p.selectVsConfigurations(platform, configurations); } } else { enableProjectActions(false); diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 28980a678..767b29141 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -1300,8 +1300,6 @@ void ImportProject::selectOneVsConfig(cppcheck::Platform::Type platform) remove = true; else if ((platform == cppcheck::Platform::Type::Win32A || platform == cppcheck::Platform::Type::Win32W) && fs.platformType == cppcheck::Platform::Type::Win64) remove = true; - else if (fs.platformType != cppcheck::Platform::Type::Win64 && platform == cppcheck::Platform::Type::Win64) - remove = true; else if (filenames.find(fs.filename) != filenames.end()) remove = true; if (remove) { @@ -1313,6 +1311,30 @@ void ImportProject::selectOneVsConfig(cppcheck::Platform::Type platform) } } +void ImportProject::selectVsConfigurations(cppcheck::Platform::Type platform, const std::vector &configurations) +{ + for (std::list::iterator it = fileSettings.begin(); it != fileSettings.end();) { + if (it->cfg.empty()) { + ++it; + continue; + } + const ImportProject::FileSettings &fs = *it; + const auto config = fs.cfg.substr(0, fs.cfg.find('|')); + bool remove = false; + if (std::find(configurations.begin(), configurations.end(), config) == configurations.end()) + remove = true; + if (platform == cppcheck::Platform::Type::Win64 && fs.platformType != platform) + remove = true; + else if ((platform == cppcheck::Platform::Type::Win32A || platform == cppcheck::Platform::Type::Win32W) && fs.platformType == cppcheck::Platform::Type::Win64) + remove = true; + if (remove) { + it = fileSettings.erase(it); + } else { + ++it; + } + } +} + std::list ImportProject::getVSConfigs() { return std::list(mAllVSConfigs.cbegin(), mAllVSConfigs.cend()); diff --git a/lib/importproject.h b/lib/importproject.h index 81077b77b..5955337a5 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -91,6 +91,7 @@ public: ImportProject& operator=(const ImportProject&) = default; void selectOneVsConfig(cppcheck::Platform::Type platform); + void selectVsConfigurations(cppcheck::Platform::Type platform, const std::vector &configurations); std::list getVSConfigs();