GUI: save dumpfiles in buildDir if possible

This commit is contained in:
Daniel Marjamäki 2017-08-03 22:54:38 +02:00
parent 0e40a4cc39
commit 5fa7a4edc4
3 changed files with 11 additions and 7 deletions

View File

@ -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;

View File

@ -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 << "<?xml version=\"1.0\"?>" << std::endl;

View File

@ -84,6 +84,7 @@ public:
/** @brief Is --dump given? */
bool dump;
std::string dumpFile;
/** @brief Is --exception-handling given */
bool exceptionHandling;