Skip to content

Commit

Permalink
Fixed rare null pointer dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Sep 25, 2018
1 parent ef34704 commit da89b81
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
Expand Up @@ -583,7 +583,7 @@ public void handleMessage(Message msg) {
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);
Expand Down Expand Up @@ -1512,6 +1512,10 @@ public void surfaceChanged(SurfaceHolder holder,
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:
Expand Down Expand Up @@ -1559,24 +1563,23 @@ public void surfaceChanged(SurfaceHolder holder,

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();
Expand Down

0 comments on commit da89b81

Please sign in to comment.