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
|
void run(void) override
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
mutex_.lock();
|
QMutexLocker locker(&mutex_);
|
||||||
condition_.wait(&mutex_);
|
condition_.wait(&mutex_);
|
||||||
|
|
||||||
if (abort_) {
|
if (abort_) {
|
||||||
mutex_.unlock();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
target_();
|
target_();
|
||||||
|
|
||||||
mutex_.unlock();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,11 +73,11 @@ class PeriodicRunner : public QThread
|
|||||||
|
|
||||||
~PeriodicRunner()
|
~PeriodicRunner()
|
||||||
{
|
{
|
||||||
mutex_.lock();
|
{
|
||||||
abort_ = true;
|
QMutexLocker locker(&mutex_);
|
||||||
condition_.wakeOne();
|
abort_ = true;
|
||||||
mutex_.unlock();
|
condition_.wakeOne();
|
||||||
|
}
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user