diff --git a/gui/checkthread.cpp b/gui/checkthread.cpp index 13e3c1dc2fe..40ec77a8c86 100644 --- a/gui/checkthread.cpp +++ b/gui/checkthread.cpp @@ -132,16 +132,17 @@ void CheckThread::run() file = mResult.getNextFile(); } - FileSettings fileSettings = mResult.getNextFileSettings(); - while (!fileSettings.filename().empty() && mState == Running) { - file = QString::fromStdString(fileSettings.filename()); + const FileSettings* fileSettings = nullptr; + mResult.getNextFileSettings(fileSettings); + while (fileSettings && mState == Running) { + file = QString::fromStdString(fileSettings->filename()); qDebug() << "Checking file" << file; - mCppcheck.check(fileSettings); - runAddonsAndTools(&fileSettings, QString::fromStdString(fileSettings.filename())); + mCppcheck.check(*fileSettings); + runAddonsAndTools(fileSettings, QString::fromStdString(fileSettings->filename())); emit fileChecked(file); if (mState == Running) - fileSettings = mResult.getNextFileSettings(); + mResult.getNextFileSettings(fileSettings); } if (mState == Running) diff --git a/gui/threadresult.cpp b/gui/threadresult.cpp index bbb373e9519..008d201c42d 100644 --- a/gui/threadresult.cpp +++ b/gui/threadresult.cpp @@ -68,15 +68,15 @@ QString ThreadResult::getNextFile() return mFiles.takeFirst(); } -FileSettings ThreadResult::getNextFileSettings() +void ThreadResult::getNextFileSettings(const FileSettings*& fs) { std::lock_guard locker(mutex); - if (mFileSettings.empty()) { - return FileSettings(""); + fs = nullptr; + if (mItNextFileSettings == mFileSettings.cend()) { + return; } - const FileSettings fs = mFileSettings.front(); - mFileSettings.pop_front(); - return fs; + fs = &(*mItNextFileSettings); + ++mItNextFileSettings; } void ThreadResult::setFiles(const QStringList &files) @@ -100,6 +100,7 @@ void ThreadResult::setProject(const ImportProject &prj) std::lock_guard locker(mutex); mFiles.clear(); mFileSettings = prj.fileSettings; + mItNextFileSettings = mFileSettings.cbegin(); mProgress = 0; mFilesChecked = 0; mTotalFiles = prj.fileSettings.size(); @@ -116,6 +117,7 @@ void ThreadResult::clearFiles() std::lock_guard locker(mutex); mFiles.clear(); mFileSettings.clear(); + mItNextFileSettings = mFileSettings.cend(); mFilesChecked = 0; mTotalFiles = 0; } diff --git a/gui/threadresult.h b/gui/threadresult.h index faea466d44d..f9611eac2d4 100644 --- a/gui/threadresult.h +++ b/gui/threadresult.h @@ -54,7 +54,7 @@ class ThreadResult : public QObject, public ErrorLogger { */ QString getNextFile(); - FileSettings getNextFileSettings(); + void getNextFileSettings(const FileSettings*& fs); /** * @brief Set list of files to check @@ -137,6 +137,7 @@ public slots: QStringList mFiles; std::list mFileSettings; + std::list::const_iterator mItNextFileSettings; /** * @brief Max progress