summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2014-04-29 13:06:58 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2014-08-20 09:44:51 +0200
commit405fff8eebe4dfe5f3fc8da1313dee76ebf0701c (patch)
tree13fd9240cc476f2fe8b8cf2b13aa0203768bb131
parentc3325f7ca35684a80a0699433037b5b67a759efc (diff)
prevent deadlocks between main thread and other thread processing a Qt event
This part of 13a34f4c6307d1bd2443cbf3fbd83bfdd8cdbafb 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 (cherry picked from commit f09d4bc2853be2fa3faa0502b8efe94ad9719731)
-rw-r--r--vcl/unx/kde4/KDEXLib.cxx8
1 files changed, 6 insertions, 2 deletions
diff --git a/vcl/unx/kde4/KDEXLib.cxx b/vcl/unx/kde4/KDEXLib.cxx
index 1c09058f08ee..86663b5fac45 100644
--- a/vcl/unx/kde4/KDEXLib.cxx
+++ b/vcl/unx/kde4/KDEXLib.cxx
@@ -297,8 +297,12 @@ void KDEXLib::Yield( bool bWait, bool bHandleAllCurrentEvents )
if( qApp->thread() == QThread::currentThread())
processYield( bWait, bHandleAllCurrentEvents );
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 );
}
}