summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAssam Boudjelthia <[email protected]>2025-08-22 02:22:00 +0300
committerAssam Boudjelthia <[email protected]>2025-08-26 22:57:43 +0300
commitcb972cd5facdd7031828c8dbd50361aa7be6590c (patch)
treef1b1af791887fd6f281304bfa11d1d74252a5b84
parent9bba7d9258aba1cd0ae5cb69279700d519a5d2f6 (diff)
Android: fix deadlock protector locking in QAndroidEventDispatcher
The order of conditions in QAndroidEventDispatcher::processEvents() causes excessive and unnecessary locking for AndroidDeadlockProtector with every call to processEvents() and in the majority of the cases it's not needed at all. QAndroidEventDispatcher is mainly used when setting the app's state or when creating the window surface, for that reason we end up with calls first locking the deadlock protector and then check m_stopRequest that most of the time is false. To avoid any issues with trying to acquire same lock over and over and to be more effecient the check for m_stopRequest needs to comes first. Pick-to: 6.5 6.8 6.9 6.10 Fixes: QTBUG-132695 Change-Id: Iaa9a019ad666e2da073454d6473bba65c6c18418 Reviewed-by: Ville Voutilainen <[email protected]>
-rw-r--r--src/plugins/platforms/android/qandroideventdispatcher.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/plugins/platforms/android/qandroideventdispatcher.cpp b/src/plugins/platforms/android/qandroideventdispatcher.cpp
index 8d1a0858445..104ebb2ee24 100644
--- a/src/plugins/platforms/android/qandroideventdispatcher.cpp
+++ b/src/plugins/platforms/android/qandroideventdispatcher.cpp
@@ -54,7 +54,7 @@ bool QAndroidEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags
{
AndroidDeadlockProtector protector;
- if (protector.acquire() && m_stopRequest.testAndSetAcquire(StopRequest, Stopping)) {
+ if (m_stopRequest.testAndSetAcquire(StopRequest, Stopping) && protector.acquire()) {
m_semaphore.acquire();
wakeUp();
}