From 5fa7a4edc4b6c807fb31f1bef3dc68f35b7bf820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 3 Aug 2017 22:54:38 +0200 Subject: [PATCH] GUI: save dumpfiles in buildDir if possible --- gui/checkthread.cpp | 15 +++++++++------ lib/cppcheck.cpp | 2 +- lib/settings.h | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/gui/checkthread.cpp b/gui/checkthread.cpp index ec3119c32..ff914b92f 100644 --- a/gui/checkthread.cpp +++ b/gui/checkthread.cpp @@ -107,7 +107,7 @@ void CheckThread::run() void CheckThread::runAddons(const QString &addonPath, const ImportProject::FileSettings *fileSettings, const QString &fileName) { - bool hasdump = false; + QString dumpFile; foreach (const QString addon, mAddons) { if (addon == "clang") { @@ -139,22 +139,25 @@ void CheckThread::runAddons(const QString &addonPath, const ImportProject::FileS else continue; - if (!hasdump) { - // TODO: Generate dump file in buildDir. - // Otherwise a mutex might be needed + if (dumpFile.isEmpty()) { const std::string buildDir = mCppcheck.settings().buildDir; mCppcheck.settings().buildDir.clear(); mCppcheck.settings().dump = true; + if (!buildDir.empty()) { + mCppcheck.settings().dumpFile = AnalyzerInformation::getAnalyzerInfoFile(buildDir, fileName.toStdString(), fileSettings ? fileSettings->cfg : std::string()) + ".dump"; + dumpFile = QString::fromStdString(mCppcheck.settings().dumpFile); + } else { + dumpFile = fileName + ".dump"; + } if (fileSettings) mCppcheck.check(*fileSettings); else mCppcheck.check(fileName.toStdString()); mCppcheck.settings().dump = false; + mCppcheck.settings().dumpFile.clear(); mCppcheck.settings().buildDir = buildDir; - hasdump = true; } - QString dumpFile = fileName + ".dump"; QString cmd = "python " + a + ' ' + dumpFile; qDebug() << cmd; QProcess process; diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 9eaaef6a8..dd0604794 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -179,7 +179,7 @@ unsigned int CppCheck::processFile(const std::string& filename, const std::strin // write dump file xml prolog std::ofstream fdump; if (_settings.dump) { - const std::string dumpfile(filename + ".dump"); + const std::string dumpfile(_settings.dumpFile.empty() ? (filename + ".dump") : _settings.dumpFile); fdump.open(dumpfile.c_str()); if (fdump.is_open()) { fdump << "" << std::endl; diff --git a/lib/settings.h b/lib/settings.h index 6e167dcff..9d4ab16fe 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -84,6 +84,7 @@ public: /** @brief Is --dump given? */ bool dump; + std::string dumpFile; /** @brief Is --exception-handling given */ bool exceptionHandling;