summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/androidjnimain.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-03-31 10:03:31 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-03-31 10:03:31 +0200
commitce9519593a0b3deb99d1dd2529770f7e9fffef92 (patch)
treec9bca05230dd68f49494240ae930bad1fe0c5956 /src/plugins/platforms/android/androidjnimain.cpp
parent509f77cca28aa3edea5523c5869bae4412ed2ccc (diff)
parent7baaec17edb06634f1d6235a55c7adbd112cba3e (diff)
Merge remote-tracking branch 'origin/5.4' into 5.5
Conflicts: mkspecs/android-g++/qmake.conf qmake/generators/unix/unixmake2.cpp src/gui/image/qimage_conversions.cpp Change-Id: Ib76264b8c2d29a0228438ec02bd97d4b97545be0
Diffstat (limited to 'src/plugins/platforms/android/androidjnimain.cpp')
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index e887a4ebdc..cf81f92e47 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"
@@ -595,11 +596,22 @@ static void updateApplicationState(JNIEnv */*env*/, jobject /*thiz*/, jint state
}
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 {