diff options
Diffstat (limited to 'src/plugins/platforms/android/qandroidinputcontext.cpp')
| -rw-r--r-- | src/plugins/platforms/android/qandroidinputcontext.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index a23d05520cd..a3848c9c2b1 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -38,6 +38,7 @@ #include "androidjnimain.h" #include "androidjniinput.h" #include "qandroideventdispatcher.h" +#include "androiddeadlockprotector.h" #include <QDebug> #include <qevent.h> #include <qguiapplication.h> @@ -519,6 +520,10 @@ bool QAndroidInputContext::isAnimating() const void QAndroidInputContext::showInputPanel() { + if (QGuiApplication::applicationState() != Qt::ApplicationActive) { + connect(qGuiApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(showInputPanelLater(Qt::ApplicationState))); + return; + } QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQueryThreadSafe(); if (query.isNull()) return; @@ -541,6 +546,14 @@ void QAndroidInputContext::showInputPanel() query->value(Qt::ImHints).toUInt()); } +void QAndroidInputContext::showInputPanelLater(Qt::ApplicationState state) +{ + if (state != Qt::ApplicationActive) + return; + disconnect(qGuiApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(showInputPanelLater(Qt::ApplicationState))); + showInputPanel(); +} + void QAndroidInputContext::hideInputPanel() { QtAndroidInput::hideSoftwareKeyboard(); @@ -642,13 +655,13 @@ jboolean QAndroidInputContext::deleteSurroundingText(jint leftLength, jint right // Android docs say the cursor must not move jboolean QAndroidInputContext::finishComposingText() { + if (m_composingText.isEmpty()) + return JNI_TRUE; // not composing + QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQueryThreadSafe(); if (query.isNull()) return JNI_FALSE; - if (m_composingText.isEmpty()) - return JNI_TRUE; // not composing - const int blockPos = getBlockPosition(query); const int localCursorPos = m_composingCursor - blockPos; @@ -986,6 +999,9 @@ QVariant QAndroidInputContext::queryFocusObjectThreadSafe(Qt::InputMethodQuery q const bool inMainThread = qGuiApp->thread() == QThread::currentThread(); if (QAndroidEventDispatcherStopper::stopped() && !inMainThread) return retval; + AndroidDeadlockProtector protector; + if (!inMainThread && !protector.acquire()) + return retval; QMetaObject::invokeMethod(this, "queryFocusObjectUnsafe", inMainThread ? Qt::DirectConnection : Qt::BlockingQueuedConnection, @@ -1003,6 +1019,9 @@ QSharedPointer<QInputMethodQueryEvent> QAndroidInputContext::focusObjectInputMet const bool inMainThread = qGuiApp->thread() == QThread::currentThread(); if (QAndroidEventDispatcherStopper::stopped() && !inMainThread) return QSharedPointer<QInputMethodQueryEvent>(); + AndroidDeadlockProtector protector; + if (!inMainThread && !protector.acquire()) + return QSharedPointer<QInputMethodQueryEvent>(); QInputMethodQueryEvent *queryEvent = 0; QMetaObject::invokeMethod(this, "focusObjectInputMethodQueryUnsafe", @@ -1040,7 +1059,9 @@ void QAndroidInputContext::sendInputMethodEventThreadSafe(QInputMethodEvent *eve const bool inMainThread = qGuiApp->thread() == QThread::currentThread(); if (QAndroidEventDispatcherStopper::stopped() && !inMainThread) return; - + AndroidDeadlockProtector protector; + if (!inMainThread && !protector.acquire()) + return; QMetaObject::invokeMethod(this, "sendInputMethodEventUnsafe", inMainThread ? Qt::DirectConnection : Qt::BlockingQueuedConnection, Q_ARG(QInputMethodEvent*, event)); |
