Android: some robustness when quitting application from onDestroy()
authorSylvain Becker <sylvain.becker@gmail.com>
Mon, 07 Jan 2019 11:35:31 +0100
changeset 125106fb31043d8a8
parent 12509 8faf3241a2b7
child 12511 0ef0e4cb7752
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();
src/core/android/SDL_android.c
     1.1 --- a/src/core/android/SDL_android.c	Sun Jan 06 20:25:54 2019 +0100
     1.2 +++ b/src/core/android/SDL_android.c	Mon Jan 07 11:35:31 2019 +0100
     1.3 @@ -800,6 +800,10 @@
     1.4      /* Inject a SDL_QUIT event */
     1.5      SDL_SendQuit();
     1.6      SDL_SendAppEvent(SDL_APP_TERMINATING);
     1.7 +    /* Robustness: clear any pending Pause */
     1.8 +    while (SDL_SemTryWait(Android_PauseSem) == 0) {
     1.9 +        /* empty */
    1.10 +    }
    1.11      /* Resume the event loop so that the app can catch SDL_QUIT which
    1.12       * should now be the top event in the event queue. */
    1.13      SDL_SemPost(Android_ResumeSem);