summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2018-11-28 14:56:45 +0100
committerAndy Shaw <andy.shaw@qt.io>2018-11-30 14:47:36 +0000
commit2afe4a1a074096a3a6476aae21e732c418717da7 (patch)
tree816ff47677ddda7ecce26caa3f57b357668e0b68 /src/plugins
parent042707a6339cff6795d8d2ea08f927924f218a7b (diff)
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 <bogdan@kdab.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.cpp7
1 files changed, 6 insertions, 1 deletions
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<void()>)
+
static void runOnQtThread(const std::function<void()> &func)
{
- QMetaObject::invokeMethod(m_androidInputContext, "safeCall", Qt::BlockingQueuedConnection, Q_ARG(std::function<void()>, func));
+ const bool block = QGuiApplication::applicationState() >= Qt::ApplicationInactive;
+ QMetaObject::invokeMethod(m_androidInputContext, "safeCall",
+ block ? Qt::BlockingQueuedConnection : Qt::QueuedConnection, Q_ARG(std::function<void()>, func));
}
static jboolean beginBatchEdit(JNIEnv */*env*/, jobject /*thiz*/)
@@ -512,6 +516,7 @@ QAndroidInputContext::QAndroidInputContext()
m_handleMode = Hidden;
updateSelectionHandles();
});
+ qRegisterMetaType<std::function<void()>>();
}
QAndroidInputContext::~QAndroidInputContext()