mirror of
https://github.com/TomHarte/CLK.git
synced 2024-07-17 13:29:02 +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() {
|
||||||
performAsync([this] {
|
if(isRunning()) {
|
||||||
this->quit();
|
performAsync([this] {
|
||||||
});
|
this->quit();
|
||||||
|
});
|
||||||
|
}
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,9 @@ void Timer::tick() {
|
|||||||
|
|
||||||
Timer::~Timer() {
|
Timer::~Timer() {
|
||||||
thread.performAsync([this] {
|
thread.performAsync([this] {
|
||||||
timer->stop();
|
if(timer) {
|
||||||
|
timer->stop();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
thread.stop();
|
thread.stop();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user