mirror of
https://github.com/TomHarte/CLK.git
synced 2024-08-16 16:28:59 +00:00
Goes further in ensuring safe shutdown.
Especially if no machine has been started.
This commit is contained in:
parent
4fdbe578cc
commit
4e83e80962
@ -25,6 +25,10 @@ class FunctionThread: public QThread {
|
|||||||
while(performerFlag.test_and_set());
|
while(performerFlag.test_and_set());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~FunctionThread() {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
|
||||||
void run() override {
|
void run() override {
|
||||||
// Gymnastics here: events posted directly to the QThread will occur on the thread
|
// 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
|
// 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() {
|
void stop() {
|
||||||
|
if(isRunning()) {
|
||||||
performAsync([this] {
|
performAsync([this] {
|
||||||
this->quit();
|
this->quit();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,9 @@ void Timer::tick() {
|
|||||||
|
|
||||||
Timer::~Timer() {
|
Timer::~Timer() {
|
||||||
thread.performAsync([this] {
|
thread.performAsync([this] {
|
||||||
|
if(timer) {
|
||||||
timer->stop();
|
timer->stop();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
thread.stop();
|
thread.stop();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user