Android quickfix: Avoid crash at shutdown

Qt Quick does a processEvents() at shutdown. On some versions of
Android, this can trigger a getTextAfterCursor() after
QGuiApplication shutdown. This patch still has a theoretical
race condition, but should reduce the crash probablity to
practically zero.

[ChangeLog][Android] Fixed bug on some devices where the application
would crash at shutdown if the virtual keyboard was open.

Task-number: QTBUG-40957
Change-Id: Iefcc10a77e3d506c32ea151c27a3e87a7be40e68
Reviewed-by: BogDan Vatra <bogdan@kde.org>
This commit is contained in:
Paul Olav Tvete 2014-08-27 10:56:53 +02:00
parent f2e4ff4fd4
commit 4c6ebe5f9e

View File

@ -995,8 +995,10 @@ Q_INVOKABLE QVariant QAndroidInputContext::queryFocusObjectUnsafe(Qt::InputMetho
QVariant QAndroidInputContext::queryFocusObjectThreadSafe(Qt::InputMethodQuery query, QVariant argument)
{
bool inMainThread = qGuiApp->thread() == QThread::currentThread();
QVariant retval;
if (!qGuiApp)
return retval;
bool inMainThread = qGuiApp->thread() == QThread::currentThread();
QMetaObject::invokeMethod(this, "queryFocusObjectUnsafe",
inMainThread ? Qt::DirectConnection : Qt::BlockingQueuedConnection,