Android: some simplification, don't need mExitCalledFromJava
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
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 5fe46e0..6e7a7f8 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
@@ -70,8 +70,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
public static NativeState mNextNativeState;
public static NativeState mCurrentNativeState;
- public static boolean mExitCalledFromJava;
-
/** If shared libraries (e.g. SDL or the native application) could not be loaded. */
public static boolean mBrokenLibraries;
@@ -179,7 +177,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
mCursors = new Hashtable<Integer, PointerIcon>();
mLastCursorID = 0;
mSDLThread = null;
- mExitCalledFromJava = false;
mBrokenLibraries = false;
mIsResumedCalled = false;
mIsSurfaceReady = false;
@@ -390,8 +387,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
return;
}
- SDLActivity.mExitCalledFromJava = true;
-
if (SDLActivity.mSDLThread != null) {
// Send Quit event to "SDLThread" thread
@@ -514,15 +509,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
}
}
- /* The native thread has finished */
- public static void handleNativeExit() {
- SDLActivity.mSDLThread = null;
- if (mSingleton != null) {
- mSingleton.finish();
- }
- }
-
-
// Messages from the SDLMain thread
static final int COMMAND_CHANGE_TITLE = 1;
static final int COMMAND_CHANGE_WINDOW_STYLE = 2;
@@ -1513,9 +1499,12 @@ class SDLMain implements Runnable {
Log.v("SDL", "Finished main function");
- // Native thread has finished, let's finish the Activity
- if (!SDLActivity.mExitCalledFromJava) {
- SDLActivity.handleNativeExit();
+ if (SDLActivity.mSingleton.isFinishing()) {
+ // Activity is already being destroyed
+ } else {
+ // Let's finish the Activity
+ SDLActivity.mSDLThread = null;
+ SDLActivity.mSingleton.finish();
}
}
}