Android: some simplification, don't need mExitCalledFromJava
authorSylvain Becker <sylvain.becker@gmail.com>
Thu, 10 Jan 2019 15:48:43 +0100
changeset 125194476dd3fec4a
parent 12518 f20cacda9d6d
child 12520 34126acf146f
Android: some simplification, don't need mExitCalledFromJava
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
     1.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Thu Jan 10 15:43:07 2019 +0100
     1.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Thu Jan 10 15:48:43 2019 +0100
     1.3 @@ -70,8 +70,6 @@
     1.4      public static NativeState mNextNativeState;
     1.5      public static NativeState mCurrentNativeState;
     1.6  
     1.7 -    public static boolean mExitCalledFromJava;
     1.8 -
     1.9      /** If shared libraries (e.g. SDL or the native application) could not be loaded. */
    1.10      public static boolean mBrokenLibraries;
    1.11  
    1.12 @@ -179,7 +177,6 @@
    1.13          mCursors = new Hashtable<Integer, PointerIcon>();
    1.14          mLastCursorID = 0;
    1.15          mSDLThread = null;
    1.16 -        mExitCalledFromJava = false;
    1.17          mBrokenLibraries = false;
    1.18          mIsResumedCalled = false;
    1.19          mIsSurfaceReady = false;
    1.20 @@ -390,8 +387,6 @@
    1.21             return;
    1.22          }
    1.23  
    1.24 -        SDLActivity.mExitCalledFromJava = true;
    1.25 -
    1.26          if (SDLActivity.mSDLThread != null) {
    1.27  
    1.28              // Send Quit event to "SDLThread" thread
    1.29 @@ -514,15 +509,6 @@
    1.30          }
    1.31      }
    1.32  
    1.33 -    /* The native thread has finished */
    1.34 -    public static void handleNativeExit() {
    1.35 -        SDLActivity.mSDLThread = null;
    1.36 -        if (mSingleton != null) {
    1.37 -            mSingleton.finish();
    1.38 -        }
    1.39 -    }
    1.40 -
    1.41 -
    1.42      // Messages from the SDLMain thread
    1.43      static final int COMMAND_CHANGE_TITLE = 1;
    1.44      static final int COMMAND_CHANGE_WINDOW_STYLE = 2;
    1.45 @@ -1513,9 +1499,12 @@
    1.46  
    1.47          Log.v("SDL", "Finished main function");
    1.48  
    1.49 -        // Native thread has finished, let's finish the Activity
    1.50 -        if (!SDLActivity.mExitCalledFromJava) {
    1.51 -            SDLActivity.handleNativeExit();
    1.52 +        if (SDLActivity.mSingleton.isFinishing()) {
    1.53 +            // Activity is already being destroyed
    1.54 +        } else {
    1.55 +            // Let's finish the Activity
    1.56 +            SDLActivity.mSDLThread = null;
    1.57 +            SDLActivity.mSingleton.finish();
    1.58          }
    1.59      }
    1.60  }