summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogDan Vatra <bogdan@kdab.com>2016-06-13 17:05:43 +0300
committerBogDan Vatra <bogdan@kdab.com>2016-08-10 14:20:01 +0000
commit23ac125bcb750575b86edfaa08448f8358260e4b (patch)
tree05e0146319a7394079ddb0f0a5164817956b0c2c
parent25b72a63fffe800f2005b21d254b0b191d263b10 (diff)
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>
-rw-r--r--src/plugins/platforms/android/androidjnimain.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp
index 671dad98b2..fe2401f561 100644
--- a/src/plugins/platforms/android/androidjnimain.cpp
+++ b/src/plugins/platforms/android/androidjnimain.cpp
@@ -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)