Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Android: be sure shared libraries are loaded in onConfigurationChanged()
This could fix a rare crash if:
- onConfigurationChanged is called before onCreate();
or
 shared libraries failed to load and onConfigurationChanged() is called
  • Loading branch information
1bsyl committed Sep 25, 2020
1 parent 955f318 commit 7ad7156
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -71,7 +71,7 @@ public enum NativeState {
public static NativeState mCurrentNativeState;

/** If shared libraries (e.g. SDL or the native application) could not be loaded. */
public static boolean mBrokenLibraries;
public static boolean mBrokenLibraries = true;

// Main components
protected static SDLActivity mSingleton;
Expand Down Expand Up @@ -174,7 +174,6 @@ public static void initialize() {
mCursors = new Hashtable<Integer, PointerIcon>();
mLastCursorID = 0;
mSDLThread = null;
mBrokenLibraries = false;
mIsResumedCalled = false;
mHasFocus = true;
mNextNativeState = NativeState.INIT;
Expand All @@ -199,6 +198,7 @@ protected void onCreate(Bundle savedInstanceState) {
String errorMsgBrokenLib = "";
try {
loadLibraries();
mBrokenLibraries = false; /* success */
} catch(UnsatisfiedLinkError e) {
System.err.println(e.getMessage());
mBrokenLibraries = true;
Expand Down Expand Up @@ -420,6 +420,10 @@ public void onConfigurationChanged(Configuration newConfig) {
Log.v(TAG, "onConfigurationChanged()");
super.onConfigurationChanged(newConfig);

if (SDLActivity.mBrokenLibraries) {
return;
}

if (mCurrentLocale == null || !mCurrentLocale.equals(newConfig.locale)) {
mCurrentLocale = newConfig.locale;
SDLActivity.onNativeLocaleChanged();
Expand Down

0 comments on commit 7ad7156

Please sign in to comment.