mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3929 System : Always lock mutex before unlocking
This commit is contained in:
parent
f09fa727fa
commit
f727a6c4ee
@ -1580,9 +1580,13 @@ std::vector<QString> RiaApplication::readFileListFromTextFile(QString listFileNa
|
|||||||
void RiaApplication::waitUntilCommandObjectsHasBeenProcessed()
|
void RiaApplication::waitUntilCommandObjectsHasBeenProcessed()
|
||||||
{
|
{
|
||||||
// Wait until all command objects have completed
|
// Wait until all command objects have completed
|
||||||
while (!m_commandQueueLock.tryLock())
|
bool mutexLockedSuccessfully = m_commandQueueLock.tryLock();
|
||||||
|
|
||||||
|
while (!mutexLockedSuccessfully)
|
||||||
{
|
{
|
||||||
processEvents();
|
processEvents();
|
||||||
|
|
||||||
|
mutexLockedSuccessfully = m_commandQueueLock.tryLock();
|
||||||
}
|
}
|
||||||
m_commandQueueLock.unlock();
|
m_commandQueueLock.unlock();
|
||||||
}
|
}
|
||||||
@ -2219,6 +2223,8 @@ void RiaApplication::executeCommandObjects()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Unlock the command queue lock when the command queue is empty
|
// Unlock the command queue lock when the command queue is empty
|
||||||
|
// Required to lock the mutex before unlocking to avoid undefined behavior
|
||||||
|
m_commandQueueLock.tryLock();
|
||||||
m_commandQueueLock.unlock();
|
m_commandQueueLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user