diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-06 19:10:10 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-04-06 19:10:25 +0200 |
commit | 20cac3d9c9c22153e9e316daff32b6050ff6be6b (patch) | |
tree | b563a89475df9afb4f40841ec371be9488d5b1ed /src/plugins/platforms/android/androidjnimain.cpp | |
parent | 8ce85d74b692392a4ea0785360156f37418cff13 (diff) | |
parent | 9eb0b09abce28b11e4915fc9c3b3e996eb19cef2 (diff) |
Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: If9fd98525b6b4ca07e5e006fc98bf372a73b8a21
Diffstat (limited to 'src/plugins/platforms/android/androidjnimain.cpp')
-rw-r--r-- | src/plugins/platforms/android/androidjnimain.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 47018bfece..19ab051162 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -42,6 +42,7 @@ #include "androidjniinput.h" #include "androidjniclipboard.h" #include "androidjnimenu.h" +#include "androiddeadlockprotector.h" #include "qandroidplatformdialoghelpers.h" #include "qandroidplatformintegration.h" #include "qandroidassetsfileenginehandler.h" @@ -600,11 +601,22 @@ static void updateApplicationState(JNIEnv */*env*/, jobject /*thiz*/, jint state QtAndroidPrivate::handlePause(); if (state <= Qt::ApplicationInactive) { + // NOTE: sometimes we will receive two consecutive suspended notifications, + // In the second suspended notification, QWindowSystemInterface::flushWindowSystemEvents() + // will deadlock since the dispatcher has been stopped in the first suspended notification. + // To avoid the deadlock we simply return if we found the event dispatcher has been stopped. + if (QAndroidEventDispatcherStopper::instance()->stopped()) + return; + // Don't send timers and sockets events anymore if we are going to hide all windows QAndroidEventDispatcherStopper::instance()->goingToStop(true); QCoreApplication::processEvents(); QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState(state)); - QWindowSystemInterface::flushWindowSystemEvents(); + { + AndroidDeadlockProtector protector; + if (protector.acquire()) + QWindowSystemInterface::flushWindowSystemEvents(); + } if (state == Qt::ApplicationSuspended) QAndroidEventDispatcherStopper::instance()->stopAll(); } else { |