Fixed #8637 (GUI: Supression filename should accept relative paths)
This commit is contained in:
parent
0c7d4eb91f
commit
b2e3af5869
|
@ -28,7 +28,10 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include "cppcheck.h"
|
#include "cppcheck.h"
|
||||||
|
#include "path.h"
|
||||||
|
|
||||||
#include "applicationlist.h"
|
#include "applicationlist.h"
|
||||||
#include "aboutdialog.h"
|
#include "aboutdialog.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
@ -56,6 +59,19 @@ static QString getDataDir(const QSettings *settings)
|
||||||
return dataDir.isEmpty() ? appPath : dataDir;
|
return dataDir.isEmpty() ? appPath : dataDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QList<Suppressions::Suppression> getCheckSuppressions(const ProjectFile &project)
|
||||||
|
{
|
||||||
|
QList<Suppressions::Suppression> 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) :
|
MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
|
||||||
mSettings(settings),
|
mSettings(settings),
|
||||||
mApplications(new ApplicationList(this)),
|
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());
|
mThread->setAddonsAndTools(mProjectFile->getAddonsAndTools(), mSettings->value(SETTINGS_MISRA_FILE).toString());
|
||||||
QString clangHeaders = mSettings->value(SETTINGS_VS_INCLUDE_PATHS).toString();
|
QString clangHeaders = mSettings->value(SETTINGS_VS_INCLUDE_PATHS).toString();
|
||||||
mThread->setClangIncludePaths(clangHeaders.split(";"));
|
mThread->setClangIncludePaths(clangHeaders.split(";"));
|
||||||
mThread->setSuppressions(mProjectFile->getSuppressions());
|
mThread->setSuppressions(getCheckSuppressions(*mProjectFile));
|
||||||
}
|
}
|
||||||
mThread->setProject(p);
|
mThread->setProject(p);
|
||||||
mThread->check(checkSettings);
|
mThread->check(checkSettings);
|
||||||
|
@ -841,8 +857,8 @@ Settings MainWindow::getCppcheckSettings()
|
||||||
tryLoadLibrary(&result.library, filename);
|
tryLoadLibrary(&result.library, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<Suppressions::Suppression> &suppressions = mProjectFile->getSuppressions();
|
|
||||||
foreach (const Suppressions::Suppression &suppression, suppressions) {
|
foreach (const Suppressions::Suppression &suppression, getCheckSuppressions(*mProjectFile)) {
|
||||||
result.nomsg.addSuppression(suppression);
|
result.nomsg.addSuppression(suppression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "ui_newsuppressiondialog.h"
|
#include "ui_newsuppressiondialog.h"
|
||||||
#include "cppcheck.h"
|
#include "cppcheck.h"
|
||||||
#include "errorlogger.h"
|
#include "errorlogger.h"
|
||||||
|
#include "suppressions.h"
|
||||||
|
|
||||||
NewSuppressionDialog::NewSuppressionDialog(QWidget *parent) :
|
NewSuppressionDialog::NewSuppressionDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
@ -41,6 +41,7 @@ Suppressions::Suppression NewSuppressionDialog::getSuppression() const
|
||||||
if (ret.errorId.empty())
|
if (ret.errorId.empty())
|
||||||
ret.errorId = "*";
|
ret.errorId = "*";
|
||||||
ret.fileName = mUI->mTextFileName->text().toStdString();
|
ret.fileName = mUI->mTextFileName->text().toStdString();
|
||||||
|
if (!mUI->mTextLineNumber->text().isEmpty())
|
||||||
ret.lineNumber = mUI->mTextLineNumber->text().toInt();
|
ret.lineNumber = mUI->mTextLineNumber->text().toInt();
|
||||||
ret.symbolName = mUI->mTextSymbolName->text().toStdString();
|
ret.symbolName = mUI->mTextSymbolName->text().toStdString();
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue