diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index c2b8c8b13..78c0abb2e 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -28,7 +28,10 @@ #include #include #include "mainwindow.h" + #include "cppcheck.h" +#include "path.h" + #include "applicationlist.h" #include "aboutdialog.h" #include "common.h" @@ -56,6 +59,19 @@ static QString getDataDir(const QSettings *settings) return dataDir.isEmpty() ? appPath : dataDir; } +static QList getCheckSuppressions(const ProjectFile &project) +{ + QList ret; + const std::string projectFilePath = Path::getPathFromFilename(project.getFilename().toStdString()); + foreach (Suppressions::Suppression suppression, project.getSuppressions()) { + if (!suppression.fileName.empty() && suppression.fileName[0]!='*' && !Path::isAbsolute(suppression.fileName)) + suppression.fileName = Path::simplifyPath(projectFilePath) + suppression.fileName; + + ret.append(suppression); + } + return ret; +} + MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) : mSettings(settings), mApplications(new ApplicationList(this)), @@ -442,7 +458,7 @@ void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, cons mThread->setAddonsAndTools(mProjectFile->getAddonsAndTools(), mSettings->value(SETTINGS_MISRA_FILE).toString()); QString clangHeaders = mSettings->value(SETTINGS_VS_INCLUDE_PATHS).toString(); mThread->setClangIncludePaths(clangHeaders.split(";")); - mThread->setSuppressions(mProjectFile->getSuppressions()); + mThread->setSuppressions(getCheckSuppressions(*mProjectFile)); } mThread->setProject(p); mThread->check(checkSettings); @@ -841,8 +857,8 @@ Settings MainWindow::getCppcheckSettings() tryLoadLibrary(&result.library, filename); } - const QList &suppressions = mProjectFile->getSuppressions(); - foreach (const Suppressions::Suppression &suppression, suppressions) { + + foreach (const Suppressions::Suppression &suppression, getCheckSuppressions(*mProjectFile)) { result.nomsg.addSuppression(suppression); } diff --git a/gui/newsuppressiondialog.cpp b/gui/newsuppressiondialog.cpp index ccce6bc8b..9fc598ae1 100644 --- a/gui/newsuppressiondialog.cpp +++ b/gui/newsuppressiondialog.cpp @@ -2,7 +2,7 @@ #include "ui_newsuppressiondialog.h" #include "cppcheck.h" #include "errorlogger.h" - +#include "suppressions.h" NewSuppressionDialog::NewSuppressionDialog(QWidget *parent) : QDialog(parent), @@ -41,7 +41,8 @@ Suppressions::Suppression NewSuppressionDialog::getSuppression() const if (ret.errorId.empty()) ret.errorId = "*"; ret.fileName = mUI->mTextFileName->text().toStdString(); - ret.lineNumber = mUI->mTextLineNumber->text().toInt(); + if (!mUI->mTextLineNumber->text().isEmpty()) + ret.lineNumber = mUI->mTextLineNumber->text().toInt(); ret.symbolName = mUI->mTextSymbolName->text().toStdString(); return ret; }