From 156be545785d959aa07bd2afd99ddfd6098ab85d Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 2 Mar 2015 12:55:37 +0100 Subject: 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 --- src/plugins/platforms/android/androidjnimain.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 { -- cgit v1.2.3