summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2019-01-03 13:33:28 +0100
committerAndy Shaw <andy.shaw@qt.io>2019-01-04 12:39:15 +0000
commit6191249259719dee6f8f6eb42289e0582f1c02bc (patch)
tree0f1994c117a8030f10be77e389d345e2f4be6bcc /src
parent3b03150aa2af76b13424c988c6c7892d19cce6c5 (diff)
Use the AndroidDeadlockProtector when using a blockingqueued connection
This amends 2afe4a1a074096a3a6476aae21e732c418717da7 to account for cases where it was crashing when it was using the QueuedConnection. The problem came from the fact it was blocking while waiting for a surface update which was pending to come later on, but the Android thread was already blocked which prevented it from being processed. Fixes: QTBUG-72101 Change-Id: I43e355cf1a7792599f23827903d065b1b1298902 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp
index 7b3546f9bb..394e284bb6 100644
--- a/src/plugins/platforms/android/qandroidinputcontext.cpp
+++ b/src/plugins/platforms/android/qandroidinputcontext.cpp
@@ -99,13 +99,12 @@ 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)
{
- const bool block = QGuiApplication::applicationState() >= Qt::ApplicationInactive;
- QMetaObject::invokeMethod(m_androidInputContext, "safeCall",
- block ? Qt::BlockingQueuedConnection : Qt::QueuedConnection, Q_ARG(std::function<void()>, func));
+ AndroidDeadlockProtector protector;
+ if (!protector.acquire())
+ return;
+ QMetaObject::invokeMethod(m_androidInputContext, "safeCall", Qt::BlockingQueuedConnection, Q_ARG(std::function<void()>, func));
}
static jboolean beginBatchEdit(JNIEnv */*env*/, jobject /*thiz*/)
@@ -516,7 +515,6 @@ QAndroidInputContext::QAndroidInputContext()
m_handleMode = Hidden;
updateSelectionHandles();
});
- qRegisterMetaType<std::function<void()>>();
}
QAndroidInputContext::~QAndroidInputContext()