Skip to content

Commit

Permalink
Fix nullptr crash on android
Browse files Browse the repository at this point in the history
nullcheck the device coming back from InputDevice.getDevice(deviceId) in new code added to sdlactivity.onkey.


java.lang.NullPointerException:
  at org.libsdl.app.SDLSurface.onKey (SDLActivity.java:1793)
  at android.view.View.dispatchKeyEvent (View.java:13321)
  at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1912)
  at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1912)
  at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1912)
  at android.view.ViewGroup.dispatchKeyEvent (ViewGroup.java:1912)
  at com.android.internal.policy.DecorView.superDispatchKeyEvent (DecorView.java:685)
  at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent (PhoneWindow.java:1869)
  at android.app.Activity.dispatchKeyEvent (Activity.java:3447)
  at org.libsdl.app.SDLActivity.dispatchKeyEvent (SDLActivity.java:496)

@dang @saml @dave
  • Loading branch information
slouken committed Aug 3, 2019
1 parent 63197c4 commit e92fe23
Showing 1 changed file with 4 additions and 1 deletion.
Expand Up @@ -1825,7 +1825,10 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {

if (source == InputDevice.SOURCE_UNKNOWN) {
InputDevice device = InputDevice.getDevice(deviceId);
source = device.getSources();
if ( device != null )
{
source = device.getSources();
}
}

if ((source & InputDevice.SOURCE_KEYBOARD) != 0) {
Expand Down

0 comments on commit e92fe23

Please sign in to comment.