Do not crash on GUI shutdown (#5288)
Seems current code for worker threads termination is too brutal which leads to crash on termination: ``` QThread::start: Thread termination error: No such process Segmentation fault (core dumped) ``` Seems better to use `quit()` and `wait()`, like in an example: https://doc.qt.io/qt-6/qthread.html#details tested: Ubuntu Linux 20
This commit is contained in:
parent
037bed5b3c
commit
8166bfc7b8
|
@ -24,6 +24,8 @@
|
||||||
#include "importproject.h"
|
#include "importproject.h"
|
||||||
#include "suppressions.h"
|
#include "suppressions.h"
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
@ -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<State> mState{Ready};
|
||||||
|
|
||||||
ThreadResult &mResult;
|
ThreadResult &mResult;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -148,7 +148,10 @@ void ThreadHandler::setThreadCount(const int count)
|
||||||
void ThreadHandler::removeThreads()
|
void ThreadHandler::removeThreads()
|
||||||
{
|
{
|
||||||
for (CheckThread* thread : mThreads) {
|
for (CheckThread* thread : mThreads) {
|
||||||
thread->terminate();
|
if (thread->isRunning()) {
|
||||||
|
thread->terminate();
|
||||||
|
thread->wait();
|
||||||
|
}
|
||||||
disconnect(thread, &CheckThread::done,
|
disconnect(thread, &CheckThread::done,
|
||||||
this, &ThreadHandler::threadDone);
|
this, &ThreadHandler::threadDone);
|
||||||
disconnect(thread, &CheckThread::fileChecked,
|
disconnect(thread, &CheckThread::fileChecked,
|
||||||
|
|
Loading…
Reference in New Issue