Android: only send Quit event to SDLThread if it's not already terminated And it avoids reporting errors using Android_Pause/ResumeSem that are NULL.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
index b47c267..38c2cd8 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
@@ -390,16 +390,18 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
return;
}
- // Send a quit message to the application
SDLActivity.mExitCalledFromJava = true;
- SDLActivity.nativeQuit();
- // Now wait for the SDL thread to quit
if (SDLActivity.mSDLThread != null) {
+
+ // Send Quit event to "SDLThread" thread
+ SDLActivity.nativeSendQuit();
+
+ // Wait for "SDLThread" thread to end
try {
SDLActivity.mSDLThread.join();
} catch(Exception e) {
- Log.v(TAG, "Problem stopping thread: " + e);
+ Log.v(TAG, "Problem stopping SDLThread: " + e);
}
}
@@ -724,7 +726,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
public static native int nativeSetupJNI();
public static native int nativeRunMain(String library, String function, Object arguments);
public static native void nativeLowMemory();
- public static native void nativeQuit();
+ public static native void nativeSendQuit();
public static native void nativePause();
public static native void nativeResume();
public static native void onNativeDropFile(String filename);
diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c
index 96bab01..9811653 100644
--- a/src/core/android/SDL_android.c
+++ b/src/core/android/SDL_android.c
@@ -122,7 +122,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeClipboardChanged)(
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeLowMemory)(
JNIEnv *env, jclass cls);
-JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)(
+JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSendQuit)(
JNIEnv *env, jclass cls);
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)(
@@ -813,12 +813,12 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeLowMemory)(
SDL_SendAppEvent(SDL_APP_LOWMEMORY);
}
-/* Quit */
-JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)(
+/* Send Quit event to "SDLThread" thread */
+JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSendQuit)(
JNIEnv *env, jclass cls)
{
/* Discard previous events. The user should have handled state storage
- * in SDL_APP_WILLENTERBACKGROUND. After nativeQuit() is called, no
+ * in SDL_APP_WILLENTERBACKGROUND. After nativeSendQuit() is called, no
* events other than SDL_QUIT and SDL_APP_TERMINATING should fire */
SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT);
/* Inject a SDL_QUIT event */