From 2afe4a1a074096a3a6476aae21e732c418717da7 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 28 Nov 2018 14:56:45 +0100 Subject: Android: Don't use blocking queued when suspending the application If the application gets suspended when a blocking queued connection is made then it will cause the application to hang when being resumed. Therefore a check is needed to still post the event to the other thread but in a non blocking manner so that it does not cause a hang on return. Fixes: QTBUG-72101 Change-Id: I6d53c97ed6d9d500559da2a9fd195226d1fc9905 Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/qandroidinputcontext.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index c5cd0b92d9..7b3546f9bb 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -99,9 +99,13 @@ static jfieldID m_selectionStartFieldID = 0; static jfieldID m_startOffsetFieldID = 0; static jfieldID m_textFieldID = 0; +Q_DECLARE_METATYPE(std::function) + static void runOnQtThread(const std::function &func) { - QMetaObject::invokeMethod(m_androidInputContext, "safeCall", Qt::BlockingQueuedConnection, Q_ARG(std::function, func)); + const bool block = QGuiApplication::applicationState() >= Qt::ApplicationInactive; + QMetaObject::invokeMethod(m_androidInputContext, "safeCall", + block ? Qt::BlockingQueuedConnection : Qt::QueuedConnection, Q_ARG(std::function, func)); } static jboolean beginBatchEdit(JNIEnv */*env*/, jobject /*thiz*/) @@ -512,6 +516,7 @@ QAndroidInputContext::QAndroidInputContext() m_handleMode = Hidden; updateSelectionHandles(); }); + qRegisterMetaType>(); } QAndroidInputContext::~QAndroidInputContext() -- cgit v1.2.3