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>
This commit is contained in:
Paul Olav Tvete 2015-03-02 12:55:37 +01:00
parent 2002103baa
commit 156be54578

View File

@ -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 {