don't crash if exiting without having successfully opened a game.

This commit is contained in:
eehouse 2010-03-13 23:11:23 +00:00
parent 0fc42fe85c
commit 6eb045d3a8

View file

@ -115,7 +115,7 @@ public class BoardActivity extends Activity implements UtilCtxt {
ab.setNegativeButton( R.string.button_no, lstnr ); ab.setNegativeButton( R.string.button_no, lstnr );
dialog = ab.create(); dialog = ab.create();
dialog.setOnDismissListener( makeODL() ); dialog.setOnDismissListener( makeODLforBlocking() );
break; break;
case PICK_TILE_REQUEST_BLK: case PICK_TILE_REQUEST_BLK:
@ -130,7 +130,7 @@ public class BoardActivity extends Activity implements UtilCtxt {
ab.setItems( m_texts, lstnr ); ab.setItems( m_texts, lstnr );
dialog = ab.create(); dialog = ab.create();
dialog.setOnDismissListener( makeODL() ); dialog.setOnDismissListener( makeODLforBlocking() );
break; break;
case QUERY_ENDGAME: case QUERY_ENDGAME:
dialog = new AlertDialog.Builder( this ) dialog = new AlertDialog.Builder( this )
@ -203,7 +203,7 @@ public class BoardActivity extends Activity implements UtilCtxt {
Utils.logf( "dict name: " + m_gi.dictName ); Utils.logf( "dict name: " + m_gi.dictName );
byte[] dictBytes = Utils.openDict( this, m_gi.dictName ); byte[] dictBytes = Utils.openDict( this, m_gi.dictName );
if ( null == dictBytes ) { if ( null == dictBytes ) {
Utils.logf( "**** unable to open dict; warn user! ****" ); Assert.fail();
finish(); finish();
} else { } else {
m_jniGamePtr = XwJNI.initJNI(); m_jniGamePtr = XwJNI.initJNI();
@ -308,17 +308,19 @@ public class BoardActivity extends Activity implements UtilCtxt {
protected void onDestroy() protected void onDestroy()
{ {
byte[] state = XwJNI.game_saveToStream( m_jniGamePtr, null ); if ( 0 != m_jniGamePtr ) {
Utils.saveGame( this, state, m_path ); byte[] state = XwJNI.game_saveToStream( m_jniGamePtr, null );
Utils.saveGame( this, state, m_path );
if ( null != m_xport ) { if ( null != m_xport ) {
m_xport.waitToStop(); m_xport.waitToStop();
} }
if ( null != m_jniThread ) { if ( null != m_jniThread ) {
m_jniThread.waitToStop(); m_jniThread.waitToStop();
Utils.logf( "onDestroy(): waitToStop() returned" ); Utils.logf( "onDestroy(): waitToStop() returned" );
}
XwJNI.game_dispose( m_jniGamePtr ); XwJNI.game_dispose( m_jniGamePtr );
m_jniGamePtr = 0; m_jniGamePtr = 0;
} }
@ -512,7 +514,7 @@ public class BoardActivity extends Activity implements UtilCtxt {
} }
} }
private DialogInterface.OnDismissListener makeODL() private DialogInterface.OnDismissListener makeODLforBlocking()
{ {
return new DialogInterface.OnDismissListener() { return new DialogInterface.OnDismissListener() {
public void onDismiss( DialogInterface di ) { public void onDismiss( DialogInterface di ) {