Skip to content

Commit

Permalink
Android: some robustness when quitting application from onDestroy()
Browse files Browse the repository at this point in the history
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();
  • Loading branch information
1bsyl committed Jan 7, 2019
1 parent 462e62e commit cfe2924
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/android/SDL_android.c
Expand Up @@ -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);
Expand Down

0 comments on commit cfe2924

Please sign in to comment.