gui: user more reliable locking
This commit is contained in:
parent
465cbfaf19
commit
75af8ccfd2
@ -60,17 +60,12 @@ class PeriodicRunner : public QThread
|
||||
void run(void) override
|
||||
{
|
||||
for (;;) {
|
||||
mutex_.lock();
|
||||
QMutexLocker locker(&mutex_);
|
||||
condition_.wait(&mutex_);
|
||||
|
||||
if (abort_) {
|
||||
mutex_.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
target_();
|
||||
|
||||
mutex_.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,11 +73,11 @@ class PeriodicRunner : public QThread
|
||||
|
||||
~PeriodicRunner()
|
||||
{
|
||||
mutex_.lock();
|
||||
abort_ = true;
|
||||
condition_.wakeOne();
|
||||
mutex_.unlock();
|
||||
|
||||
{
|
||||
QMutexLocker locker(&mutex_);
|
||||
abort_ = true;
|
||||
condition_.wakeOne();
|
||||
}
|
||||
wait();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user