Android: some simplification, don't need mExitCalledFromJava

This commit is contained in:
Sylvain Becker 2019-01-10 15:48:43 +01:00
parent 66fbfe1d00
commit 5c11e5ef92

View File

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