Fixed rare null pointer dereference
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 63 64 65
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 a624fb5..0ece200 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
@@ -583,7 +583,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
- View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.INVISIBLE;
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.INVISIBLE;
window.getDecorView().setSystemUiVisibility(flags);
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
@@ -1512,6 +1512,10 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
int format, int width, int height) {
Log.v("SDL", "surfaceChanged()");
+ if (SDLActivity.mSingleton == null) {
+ return;
+ }
+
int sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565 by default
switch (format) {
case PixelFormat.A_8:
@@ -1559,24 +1563,23 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
mWidth = width;
mHeight = height;
- int nDeviceWidth = width;
- int nDeviceHeight = height;
- try
- {
- if ( android.os.Build.VERSION.SDK_INT >= 17 )
- {
- android.util.DisplayMetrics realMetrics = new android.util.DisplayMetrics();
- mDisplay.getRealMetrics( realMetrics );
- nDeviceWidth = realMetrics.widthPixels;
- nDeviceHeight = realMetrics.heightPixels;
- }
- }
- catch ( java.lang.Throwable throwable ) {}
-
- Log.v("SDL", "Window size: " + width + "x" + height);
- Log.v("SDL", "Device size: " + nDeviceWidth + "x" + nDeviceHeight);
- SDLActivity.onNativeResize(width, height, nDeviceWidth, nDeviceHeight, sdlFormat, mDisplay.getRefreshRate());
+ int nDeviceWidth = width;
+ int nDeviceHeight = height;
+ try
+ {
+ if ( android.os.Build.VERSION.SDK_INT >= 17 )
+ {
+ android.util.DisplayMetrics realMetrics = new android.util.DisplayMetrics();
+ mDisplay.getRealMetrics( realMetrics );
+ nDeviceWidth = realMetrics.widthPixels;
+ nDeviceHeight = realMetrics.heightPixels;
+ }
+ }
+ catch ( java.lang.Throwable throwable ) {}
+ Log.v("SDL", "Window size: " + width + "x" + height);
+ Log.v("SDL", "Device size: " + nDeviceWidth + "x" + nDeviceHeight);
+ SDLActivity.onNativeResize(width, height, nDeviceWidth, nDeviceHeight, sdlFormat, mDisplay.getRefreshRate());
boolean skip = false;
int requestedOrientation = SDLActivity.mSingleton.getRequestedOrientation();