Kaydet (Commit) f09d4bc2 authored tarafından Luboš Luňák's avatar Luboš Luňák

prevent deadlocks between main thread and other thread processing a Qt event

This part of 13a34f4c was correct. The main
thread will deadlock on the yield mutex if the calling thread does not release
it before waiting on the main thread.

Change-Id: I6692473457258b791c131e8bdb459b06b01550f7
üst ea391abb
...@@ -297,8 +297,12 @@ void KDEXLib::Yield( bool bWait, bool bHandleAllCurrentEvents ) ...@@ -297,8 +297,12 @@ void KDEXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
if( qApp->thread() == QThread::currentThread()) if( qApp->thread() == QThread::currentThread())
processYield( bWait, bHandleAllCurrentEvents ); processYield( bWait, bHandleAllCurrentEvents );
else else
{ // if this deadlocks, event processing needs to go into a separate thread {
// or some other solution needs to be found // we were called from another thread;
// release the yield lock to prevent deadlock with the main thread
// (it's ok to release it here, since even normal processYield() would
// temporarily do it while checking for new events)
SalYieldMutexReleaser aReleaser;
Q_EMIT processYieldSignal( bWait, bHandleAllCurrentEvents ); Q_EMIT processYieldSignal( bWait, bHandleAllCurrentEvents );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment