From 5c11e5ef92ce75dac7f70d497a66f56d45ddf39b Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Thu, 10 Jan 2019 15:48:43 +0100 Subject: [PATCH] Android: some simplification, don't need mExitCalledFromJava --- .../main/java/org/libsdl/app/SDLActivity.java | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) 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 5fe46e098..6e7a7f81a 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(); 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(); } } }