Browse Source

Android: bailout in ComponentPeerView’s callbacks if underlying host is deleted.

Previously we saw a crash in onTouchEvent due to host being 0 while the callback was called. Just as a precaution we add this check to other callbacks too.
tags/2021-05-28
Lukasz Kozakiewicz 8 years ago
parent
commit
9527e077b1
1 changed files with 18 additions and 0 deletions
  1. +18
    -0
      modules/juce_core/native/java/JuceAppActivity.java

+ 18
- 0
modules/juce_core/native/java/JuceAppActivity.java View File

@@ -566,6 +566,9 @@ public class JuceAppActivity extends Activity
@Override
public void onDraw (Canvas canvas)
{
if (host == 0)
return;
handlePaint (host, canvas, paint);
}
@@ -657,6 +660,9 @@ public class JuceAppActivity extends Activity
@Override
public boolean onKeyDown (int keyCode, KeyEvent event)
{
if (host == 0)
return false;
switch (keyCode)
{
case KeyEvent.KEYCODE_VOLUME_UP:
@@ -679,6 +685,9 @@ public class JuceAppActivity extends Activity
@Override
public boolean onKeyUp (int keyCode, KeyEvent event)
{
if (host == 0)
return false;
handleKeyUp (host, keyCode, event.getUnicodeChar());
return true;
}
@@ -686,6 +695,9 @@ public class JuceAppActivity extends Activity
@Override
public boolean onKeyMultiple (int keyCode, int count, KeyEvent event)
{
if (host == 0)
return false;
if (keyCode != KeyEvent.KEYCODE_UNKNOWN || event.getAction() != KeyEvent.ACTION_MULTIPLE)
return super.onKeyMultiple (keyCode, count, event);
@@ -718,6 +730,9 @@ public class JuceAppActivity extends Activity
@Override
protected void onSizeChanged (int w, int h, int oldw, int oldh)
{
if (host == 0)
return;
super.onSizeChanged (w, h, oldw, oldh);
viewSizeChanged (host);
}
@@ -734,6 +749,9 @@ public class JuceAppActivity extends Activity
@Override
public void onFocusChange (View v, boolean hasFocus)
{
if (host == 0)
return;
if (v == this)
focusChanged (host, hasFocus);
}


Loading…
Cancel
Save