@@ -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+
121130MainWindow::MainWindow (TranslationHandler* th, QSettings* settings) :
122131 mSettings(settings),
123132 mApplications(new ApplicationList(this )),
@@ -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 std::list<std::string> sourcefiles = toStdStringList<std::list<std::string>>(fileNames);
704710 AnalyzerInformation::writeFilesTxt (checkSettings.buildDir , sourcefiles, {});
705711 }
706712
@@ -1155,9 +1161,7 @@ bool MainWindow::getCppcheckSettings(Settings& settings, Suppressions& supprs)
11551161
11561162 const QString platform = mProjectFile ->getPlatform ();
11571163 if (platform.endsWith (" .xml" )) {
1158- std::vector<std::string> paths;
1159- for (const QString& p: mProjectFile ->getSearchPaths (" platform" ))
1160- paths.emplace_back (p.toStdString ());
1164+ const std::vector<std::string> paths = toStdStringList (mProjectFile ->getSearchPaths (" platform" ));
11611165 settings.platform .loadFromFile (paths, platform.toStdString ());
11621166 } else {
11631167 for (int i = Platform::Type::Native; i <= Platform::Type::Unix64; i++) {
0 commit comments