diff --git a/src/ui/control/controlworker.cpp b/src/ui/control/controlworker.cpp index 2471fc38..ea045af1 100644 --- a/src/ui/control/controlworker.cpp +++ b/src/ui/control/controlworker.cpp @@ -16,7 +16,9 @@ ControlWorker::ControlWorker(QSystemSemaphore *semaphore, void ControlWorker::run() { - while (m_semaphore->acquire() && !m_aborted) { + QMutexLocker locker(&m_mutex); + + while (!m_aborted && m_semaphore->acquire()) { processRequest(); } } @@ -26,6 +28,8 @@ void ControlWorker::abort() m_aborted = true; m_semaphore->release(); + + m_mutex.lock(); } bool ControlWorker::post(const QString &scriptPath, diff --git a/src/ui/control/controlworker.h b/src/ui/control/controlworker.h index bee13ea8..06206ea7 100644 --- a/src/ui/control/controlworker.h +++ b/src/ui/control/controlworker.h @@ -1,6 +1,7 @@ #ifndef CONTROLWORKER_H #define CONTROLWORKER_H +#include #include #include @@ -44,6 +45,8 @@ private: QSystemSemaphore *m_semaphore; QSharedMemory *m_sharedMemory; + + QMutex m_mutex; }; #endif // CONTROLWORKER_H