diff options
author | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2022-03-27 15:50:42 +0300 |
---|---|---|
committer | Jarkko Koivikko <jarkko.koivikko@code-q.fi> | 2022-04-05 12:06:23 +0300 |
commit | 8bca441b6f65c532915cf3e93ecbe8a5cd2750a9 (patch) | |
tree | e134e6c57cce7fb5149391fbfada50428af256f0 /src/plugins/platforms/android/androiddeadlockprotector.h | |
parent | e6c80fc01179a0752357bad35d3e9e9068c4be84 (diff) |
Android: Fix deadlock caused by a race between permissions query and IM
Android permissions query blocks Qt main thread. If the input method
was activated before the permissions query started, android would try
to invoke input method before returning back to permissions query.
This will cause a deadlock.
Fix the issue by moving the deadlock counter to Qt core and
incrementing the value before the permissions query. This will prevent
the input method queries to enter Qt main thread.
Fixes: QTBUG-99484
Pick-to: 6.2 6.3 6.3.0
Change-Id: I54ea59578880cde4095c26fa2a6a264c4dc1b7ff
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/plugins/platforms/android/androiddeadlockprotector.h')
-rw-r--r-- | src/plugins/platforms/android/androiddeadlockprotector.h | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/plugins/platforms/android/androiddeadlockprotector.h b/src/plugins/platforms/android/androiddeadlockprotector.h index 7fa5bcfcb9..9092eda78b 100644 --- a/src/plugins/platforms/android/androiddeadlockprotector.h +++ b/src/plugins/platforms/android/androiddeadlockprotector.h @@ -40,31 +40,25 @@ #ifndef ANDROID_DEADLOCKPROTECTOR_H #define ANDROID_DEADLOCKPROTECTOR_H -#include <QAtomicInt> +#include <QtCore/private/qjnihelpers_p.h> QT_BEGIN_NAMESPACE class AndroidDeadlockProtector { public: - AndroidDeadlockProtector() - : m_acquired(0) - { - } - ~AndroidDeadlockProtector() { if (m_acquired) - s_blocked.storeRelease(0); + QtAndroidPrivate::releaseAndroidDeadlockProtector(); } bool acquire() { - m_acquired = s_blocked.testAndSetAcquire(0, 1); + m_acquired = QtAndroidPrivate::acquireAndroidDeadlockProtector(); return m_acquired; } private: - static QAtomicInt s_blocked; - int m_acquired; + bool m_acquired = false; }; QT_END_NAMESPACE |