diff options
| author | Frederik Gladhorn <[email protected]> | 2014-10-20 19:12:23 +0200 |
|---|---|---|
| committer | Frederik Gladhorn <[email protected]> | 2014-10-20 19:12:25 +0200 |
| commit | 3361fcbc28be96262d22fd2b024c85fbcbc61462 (patch) | |
| tree | 48976f337b3885971dc1976b9a27cec5e7dfa2ec /src/plugins/platforms/android/qandroidinputcontext.cpp | |
| parent | dc612acdc6577594c8f61345cea2de549d7aae34 (diff) | |
| parent | 5e342f6f041208d142d97202f61179d7163eb773 (diff) | |
Merge remote-tracking branch 'origin/5.4' into dev
Change-Id: If7e51514ed6832750e3ad967e4d322ccf920d2bb
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)); |
