ExcitedLinuxUser

combined-patch

Aug 28th, 2023
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. diff --git a/src/plugins/platforms/android/androidjniaccessibility.cpp b/src/plugins/platforms/android/androidjniaccessibility.cpp
  2. index b5783bb67a..2211eb07d9 100644
  3. --- a/src/plugins/platforms/android/androidjniaccessibility.cpp
  4. +++ b/src/plugins/platforms/android/androidjniaccessibility.cpp
  5. @@ -37,6 +37,7 @@
  6. **
  7. ****************************************************************************/
  8.  
  9. +#include "androiddeadlockprotector.h"
  10. #include "androidjniaccessibility.h"
  11. #include "androidjnimain.h"
  12. #include "qandroidplatformintegration.h"
  13. @@ -96,7 +97,21 @@ namespace QtAndroidAccessibility
  14. template <typename Func, typename Ret>
  15. void runInObjectContext(QObject *context, Func &&func, Ret *retVal)
  16. {
  17. - QMetaObject::invokeMethod(context, func, Qt::BlockingQueuedConnection, retVal);
  18. + AndroidDeadlockProtector protector;
  19. + if (!protector.acquire()) {
  20. + __android_log_print(ANDROID_LOG_WARN, m_qtTag,
  21. + "Could not run accessibility call in object context, accessing "
  22. + "main thread could lead to deadlock");
  23. + return;
  24. + }
  25. +
  26. + if (!QtAndroid::blockEventLoopsWhenSuspended()
  27. + || QGuiApplication::applicationState() != Qt::ApplicationSuspended) {
  28. + QMetaObject::invokeMethod(context, func, Qt::BlockingQueuedConnection, retVal);
  29. + } else {
  30. + __android_log_print(ANDROID_LOG_WARN, m_qtTag,
  31. + "Could not run accessibility call in object context, event loop suspended.");
  32. + }
  33. }
  34.  
  35. void initialize()
  36.  
Advertisement
Add Comment
Please, Sign In to add comment