1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

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.
This commit is contained in:
Lukasz Kozakiewicz 2017-09-28 15:35:31 +02:00
parent aa3d1c1564
commit 9527e077b1

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);
}