Hi,

I have this situation:
One thread class that needs to protect a QQueue but also needs to return dequeued value.

Qt Code:
  1. bool myThread::getResult()
  2. {
  3. m_qMutex.lock();
  4. return m_qQueue.dequeue();
  5. m_qMutex.unlock(); //This will never be executed because of return statment, and will cause a deadlock
  6. }
To copy to clipboard, switch view to plain text mode 

So, how can I do this in a correct way. One solution is to get the mutex of the thread from the caller object and lock and unlock there but I want to know if there is a more elegant solution.

Thanks,