1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-07 23:29:06 +00:00

Goes further in ensuring safe shutdown.

Especially if no machine has been started.
This commit is contained in:
Thomas Harte 2020-06-19 20:17:47 -04:00
parent 4fdbe578cc
commit 4e83e80962
2 changed files with 12 additions and 4 deletions

View File

@ -25,6 +25,10 @@ class FunctionThread: public QThread {
while(performerFlag.test_and_set());
}
~FunctionThread() {
stop();
}
void run() override {
// Gymnastics here: events posted directly to the QThread will occur on the thread
// that created the QThread. To have events occur within a QThread, they have to be
@ -35,9 +39,11 @@ class FunctionThread: public QThread {
}
void stop() {
performAsync([this] {
this->quit();
});
if(isRunning()) {
performAsync([this] {
this->quit();
});
}
wait();
}

View File

@ -34,7 +34,9 @@ void Timer::tick() {
Timer::~Timer() {
thread.performAsync([this] {
timer->stop();
if(timer) {
timer->stop();
}
});
thread.stop();
}