diff --git a/gui/checkthread.h b/gui/checkthread.h index 9a1fea3e6..d74ec2514 100644 --- a/gui/checkthread.h +++ b/gui/checkthread.h @@ -24,6 +24,8 @@ #include "importproject.h" #include "suppressions.h" +#include + #include #include #include @@ -118,9 +120,9 @@ protected: }; /** - * @brief Thread's current execution state. + * @brief Thread's current execution state. Can be changed from outside */ - State mState = Ready; + std::atomic mState{Ready}; ThreadResult &mResult; /** diff --git a/gui/threadhandler.cpp b/gui/threadhandler.cpp index 43faf2aea..6e99afe04 100644 --- a/gui/threadhandler.cpp +++ b/gui/threadhandler.cpp @@ -148,7 +148,10 @@ void ThreadHandler::setThreadCount(const int count) void ThreadHandler::removeThreads() { for (CheckThread* thread : mThreads) { - thread->terminate(); + if (thread->isRunning()) { + thread->terminate(); + thread->wait(); + } disconnect(thread, &CheckThread::done, this, &ThreadHandler::threadDone); disconnect(thread, &CheckThread::fileChecked,