diff --git a/gui/checkthread.cpp b/gui/checkthread.cpp index a36680c64bc..3d1a44a9a18 100644 --- a/gui/checkthread.cpp +++ b/gui/checkthread.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -110,11 +111,11 @@ CheckThread::CheckThread(ThreadResult &result) : mResult(result) {} -void CheckThread::setSettings(const Settings &settings, Suppressions& supprs) +void CheckThread::setSettings(const Settings &settings, std::shared_ptr supprs) { mFiles.clear(); mSettings = settings; // this is a copy - mSuppressions = &supprs; + mSuppressions = std::move(supprs); } void CheckThread::analyseWholeProgram(const QStringList &files, const std::string& ctuInfo) diff --git a/gui/checkthread.h b/gui/checkthread.h index fc5fd393d5a..827e75f1247 100644 --- a/gui/checkthread.h +++ b/gui/checkthread.h @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -55,7 +56,7 @@ class CheckThread : public QThread { * @param settings settings for cppcheck * @param supprs suppressions for cppcheck */ - void setSettings(const Settings &settings, Suppressions& supprs); + void setSettings(const Settings &settings, std::shared_ptr supprs); /** * @brief Run whole program analysis @@ -132,7 +133,7 @@ class CheckThread : public QThread { ThreadResult &mResult; Settings mSettings; - Suppressions* mSuppressions{}; + std::shared_ptr mSuppressions; private: void runAddonsAndTools(const Settings& settings, const FileSettings *fileSettings, const QString &fileName); diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 618de4352d6..15ac3936288 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -542,8 +543,8 @@ void MainWindow::saveSettings() const void MainWindow::doAnalyzeProject(ImportProject p, const bool checkLibrary, const bool checkConfiguration) { Settings checkSettings; - Suppressions supprs; - if (!getCppcheckSettings(checkSettings, supprs)) + auto supprs = std::make_shared(); + if (!getCppcheckSettings(checkSettings, *supprs)) return; clearResults(); @@ -613,8 +614,8 @@ void MainWindow::doAnalyzeFiles(const QStringList &files, const bool checkLibrar return; Settings checkSettings; - Suppressions supprs; - if (!getCppcheckSettings(checkSettings, supprs)) + auto supprs = std::make_shared(); + if (!getCppcheckSettings(checkSettings, *supprs)) return; clearResults(); @@ -1348,8 +1349,8 @@ void MainWindow::reAnalyzeSelected(const QStringList& files) } Settings checkSettings; - Suppressions supprs; - if (!getCppcheckSettings(checkSettings, supprs)) + auto supprs = std::make_shared(); + if (!getCppcheckSettings(checkSettings, *supprs)) return; // Clear details, statistics and progress @@ -1383,8 +1384,8 @@ void MainWindow::reAnalyze(bool all) return; Settings checkSettings; - Suppressions supprs; - if (!getCppcheckSettings(checkSettings, supprs)) + auto supprs = std::make_shared(); + if (!getCppcheckSettings(checkSettings, *supprs)) return; // Clear details, statistics and progress diff --git a/gui/threadhandler.cpp b/gui/threadhandler.cpp index f72bbdc53a5..fecfb44b23b 100644 --- a/gui/threadhandler.cpp +++ b/gui/threadhandler.cpp @@ -83,7 +83,7 @@ void ThreadHandler::setCheckFiles(const QStringList& files) } } -void ThreadHandler::check(const Settings &settings, Suppressions& supprs) +void ThreadHandler::check(const Settings &settings, const std::shared_ptr& supprs) { if (mResults.getFileCount() == 0 || mRunningThreadCount > 0 || settings.jobs == 0) { qDebug() << "Can't start checking if there's no files to check or if check is in progress."; diff --git a/gui/threadhandler.h b/gui/threadhandler.h index ec2c9b81260..49a326933b0 100644 --- a/gui/threadhandler.h +++ b/gui/threadhandler.h @@ -23,6 +23,7 @@ #include "suppressions.h" #include "threadresult.h" +#include #include #include @@ -117,7 +118,7 @@ class ThreadHandler : public QObject { * @param settings Settings for checking * @param supprs Suppressions for checking */ - void check(const Settings &settings, Suppressions& supprs); + void check(const Settings &settings, const std::shared_ptr& supprs); /** * @brief Set files to check