2
0
Эх сурвалжийг харах

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();
Sylvain Becker 6 жил өмнө
parent
commit
cfe2924d07

+ 4 - 0
src/core/android/SDL_android.c

@@ -800,6 +800,10 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)(
     /* Inject a SDL_QUIT event */
     /* Inject a SDL_QUIT event */
     SDL_SendQuit();
     SDL_SendQuit();
     SDL_SendAppEvent(SDL_APP_TERMINATING);
     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
     /* Resume the event loop so that the app can catch SDL_QUIT which
      * should now be the top event in the event queue. */
      * should now be the top event in the event queue. */
     SDL_SemPost(Android_ResumeSem);
     SDL_SemPost(Android_ResumeSem);