diff --git a/src/Gui/CommandTest.cpp b/src/Gui/CommandTest.cpp index 3f4cc9b1e6af..243eac15eb30 100644 --- a/src/Gui/CommandTest.cpp +++ b/src/Gui/CommandTest.cpp @@ -27,6 +27,7 @@ # include # include # include +# include # include # include # include @@ -294,10 +295,10 @@ CmdTestProgress1::CmdTestProgress1() void CmdTestProgress1::activated(int iMsg) { + QMutex mutex; + QMutexLocker ml(&mutex); try { - QMutex mutex; - mutex.lock(); unsigned long steps = 1000; Base::SequencerLauncher seq("Starting progress bar", steps); @@ -306,8 +307,6 @@ void CmdTestProgress1::activated(int iMsg) seq.next(true); QWaitCondition().wait(&mutex, 30); } - - mutex.unlock(); } catch (...) { @@ -337,10 +336,11 @@ CmdTestProgress2::CmdTestProgress2() void CmdTestProgress2::activated(int iMsg) { + QMutex mutex; + QMutexLocker ml(&mutex); + try { - QMutex mutex; - mutex.lock(); unsigned long steps = 1000; Base::SequencerLauncher seq("Starting progress bar", steps); @@ -378,11 +378,12 @@ CmdTestProgress3::CmdTestProgress3() void CmdTestProgress3::activated(int iMsg) { + QMutex mutex; + QMutexLocker ml(&mutex); + try { // level 1 - QMutex mutex; - mutex.lock(); unsigned long steps = 5; Base::SequencerLauncher seq1("Starting progress bar", steps); for (unsigned long i=0; isteps;i++) @@ -519,7 +522,6 @@ class BarThread : public QThread seq.next(true); QWaitCondition().wait(&mutex, 5); } - mutex.unlock(); } catch (...) { @@ -662,27 +664,23 @@ class TestConsoleObserver : public Base::ConsoleObserver } virtual void Warning(const char * msg) { - mutex.lock(); + QMutexLocker ml(&mutex); matchWrn += strcmp(msg, "Write a warning to the console output.\n"); - mutex.unlock(); } virtual void Message(const char * msg) { - mutex.lock(); + QMutexLocker ml(&mutex); matchMsg += strcmp(msg, "Write a message to the console output.\n"); - mutex.unlock(); } virtual void Error(const char * msg) { - mutex.lock(); + QMutexLocker ml(&mutex); matchErr += strcmp(msg, "Write an error to the console output.\n"); - mutex.unlock(); } virtual void Log(const char * msg) { - mutex.lock(); + QMutexLocker ml(&mutex); matchLog += strcmp(msg, "Write a log to the console output.\n"); - mutex.unlock(); } }; diff --git a/src/Gui/Quarter/SignalThread.cpp b/src/Gui/Quarter/SignalThread.cpp index bcd9b78c6ee4..2b7254d3ceaa 100644 --- a/src/Gui/Quarter/SignalThread.cpp +++ b/src/Gui/Quarter/SignalThread.cpp @@ -30,6 +30,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \**************************************************************************/ +#include + #include "SignalThread.h" using namespace SIM::Coin3D::Quarter; @@ -47,25 +49,23 @@ void SignalThread::trigger(void) { // lock first to make sure the QThread is actually waiting for a signal - this->mutex.lock(); + QMutexLocker ml(&this->mutex); this->waitcond.wakeOne(); - this->mutex.unlock(); } void SignalThread::stopThread(void) { - this->mutex.lock(); + QMutexLocker ml(&this->mutex); this->isstopped = true; this->waitcond.wakeOne(); - this->mutex.unlock(); } void SignalThread::run(void) { - this->mutex.lock(); + QMutexLocker ml(&this->mutex); while (!this->isstopped) { // just wait, and trigger every time we receive a signal this->waitcond.wait(&this->mutex); @@ -73,5 +73,4 @@ SignalThread::run(void) emit triggerSignal(); } } - this->mutex.unlock(); } diff --git a/src/Gui/Splashscreen.cpp b/src/Gui/Splashscreen.cpp index a200776204c6..0e6610abefa2 100644 --- a/src/Gui/Splashscreen.cpp +++ b/src/Gui/Splashscreen.cpp @@ -134,7 +134,7 @@ class SplashObserver : public Base::ConsoleObserver splash->showMessage(msg.replace(QLatin1String("\n"), QString()), alignment, textColor); QMutex mutex; - mutex.lock(); + QMutexLocker ml(&mutex); QWaitCondition().wait(&mutex, 50); }