summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-03-02 12:55:37 +0100
committerPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-03-11 10:46:43 +0000
commit156be545785d959aa07bd2afd99ddfd6098ab85d (patch)
treec13bcb3b1ca8775dcc1c785472a6fdb0dc5a13e7 /src/plugins/platforms/android
parent2002103baac593e9193d9501dc0e1b1e9e28446a (diff)
Avoid deadlock when suspending app at startup
QWindowSystemInterface::flushWindowSystemEvents() is a synchronous call. This will cause a deadlock if the GUI thread is waiting for an OpenGL surface at the same time. Add deadlock protection to this case as well. Task-number: QTBUG-44721 Change-Id: Id26370f6e07011dbcd861617bf96f59e85837db6 Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms/android')
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index 00ef8f670a..721c3f6f54 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"
@@ -604,7 +605,11 @@ static void updateApplicationState(JNIEnv */*env*/, jobject /*thiz*/, jint state
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 {