summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Becker <sylvain.becker@gmail.com>2019-01-07 11:35:31 +0100
committerSylvain Becker <sylvain.becker@gmail.com>2019-01-07 11:35:31 +0100
commit3b966c66ff62d197fa908fde3fc3dc0b4bec4939 (patch)
treeaadf49fb18895bbe6dec95750292e76d80ccfde7
parente893a26dfc86389397003efbcc190aca9d9afe34 (diff)
Android: some robustness when quitting application from onDestroy()
Make sure there is not pending Pause accumulated, so the the application doesn't remain paused and stucked in onDestroy(). Can be tested by adding: SDLActivity.nativePause(); SDLActivity.nativePause(); mSingleton.finish();
-rw-r--r--src/core/android/SDL_android.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index b9b9b3be92..7de6b4b1ff 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -800,6 +800,10 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)(
/* Inject a SDL_QUIT event */
SDL_SendQuit();
SDL_SendAppEvent(SDL_APP_TERMINATING);
+ /* Robustness: clear any pending Pause */
+ while (SDL_SemTryWait(Android_PauseSem) == 0) {
+ /* empty */
+ }
/* Resume the event loop so that the app can catch SDL_QUIT which
* should now be the top event in the event queue. */
SDL_SemPost(Android_ResumeSem);