Use the AndroidDeadlockProtector when using a blockingqueued connection

This amends 2afe4a1a07 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>
bb10
Andy Shaw 2019-01-03 13:33:28 +01:00
parent 3b03150aa2
commit 6191249259
1 changed files with 4 additions and 6 deletions

View File

@ -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()