src/core/android/SDL_android.c
changeset 7910 261addaa47d0
parent 7907 24b4e98c6010
child 7926 2d2a85852f74
     1.1 --- a/src/core/android/SDL_android.c	Wed Nov 06 09:48:45 2013 -0300
     1.2 +++ b/src/core/android/SDL_android.c	Wed Nov 06 11:23:24 2013 -0300
     1.3 @@ -283,9 +283,16 @@
     1.4  void Java_org_libsdl_app_SDLActivity_nativeQuit(
     1.5                                      JNIEnv* env, jclass cls)
     1.6  {
     1.7 +    /* Discard previous events. The user should have handled state storage
     1.8 +     * in SDL_APP_WILLENTERBACKGROUND. After nativeQuit() is called, no
     1.9 +     * events other than SDL_QUIT and SDL_APP_TERMINATING should fire */
    1.10 +    SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
    1.11      /* Inject a SDL_QUIT event */
    1.12      SDL_SendQuit();
    1.13      SDL_SendAppEvent(SDL_APP_TERMINATING);
    1.14 +    /* Resume the event loop so that the app can catch SDL_QUIT which
    1.15 +     * should now be the top event in the event queue. */
    1.16 +    if (!SDL_SemValue(Android_ResumeSem)) SDL_SemPost(Android_ResumeSem);
    1.17  }
    1.18  
    1.19  /* Pause */