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>
This commit is contained in:
Andy Shaw 2018-11-28 14:56:45 +01:00
parent 042707a633
commit 2afe4a1a07

View File

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