Android: don't wait if the event loop is stopped
QAndroidEventDispatcherStopper is stopped when the application is in background and the user uses the task manager to kill the task. If the application has services the task manager doesn't kills it, but instead it tries to gently terminate the activity. The problem is that the activity is still backgrounded (meaning that the Qt event loop is freezed), therefore terminateQt will hang. Task-number: QTBUG-54012 Change-Id: I6e333cbcaf41e9e298eeb8b2b0bc3adcf446783f Reviewed-by: Christian Stromme <christian.stromme@qt.io>
This commit is contained in:
parent
25b72a63ff
commit
23ac125bcb
@ -539,8 +539,11 @@ static void quitQtAndroidPlugin(JNIEnv *env, jclass /*clazz*/)
|
||||
|
||||
static void terminateQt(JNIEnv *env, jclass /*clazz*/)
|
||||
{
|
||||
sem_wait(&m_terminateSemaphore);
|
||||
sem_destroy(&m_terminateSemaphore);
|
||||
// QAndroidEventDispatcherStopper is stopped when the user uses the task manager to kill the application
|
||||
if (!QAndroidEventDispatcherStopper::instance()->stopped()) {
|
||||
sem_wait(&m_terminateSemaphore);
|
||||
sem_destroy(&m_terminateSemaphore);
|
||||
}
|
||||
env->DeleteGlobalRef(m_applicationClass);
|
||||
env->DeleteGlobalRef(m_classLoaderObject);
|
||||
if (m_resourcesObj)
|
||||
@ -558,8 +561,11 @@ static void terminateQt(JNIEnv *env, jclass /*clazz*/)
|
||||
m_androidPlatformIntegration = nullptr;
|
||||
delete m_androidAssetsFileEngineHandler;
|
||||
m_androidAssetsFileEngineHandler = nullptr;
|
||||
sem_post(&m_exitSemaphore);
|
||||
pthread_join(m_qtAppThread, nullptr);
|
||||
|
||||
if (!QAndroidEventDispatcherStopper::instance()->stopped()) {
|
||||
sem_post(&m_exitSemaphore);
|
||||
pthread_join(m_qtAppThread, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
static void setSurface(JNIEnv *env, jobject /*thiz*/, jint id, jobject jSurface, jint w, jint h)
|
||||
|
Loading…
Reference in New Issue
Block a user