From 98d4da136ebfee9cb33bca29833587ac6c3c9195 Mon Sep 17 00:00:00 2001 From: eehouse Date: Sat, 17 Apr 2010 04:15:36 +0000 Subject: [PATCH] don't pass null CommonPrefs instance to jni. Fixes crash when closing prefs window that was on top of board. 05d8b4c383a5520ce1e0691f25e3af89f69b7cf5 introduced this change by switching to making multiple calls to unload game. --- .../org/eehouse/android/xw4/BoardActivity.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java index 38b2143ca..38ddef7de 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -70,7 +70,7 @@ public class BoardActivity extends Activity implements UtilCtxt { private int m_dlgTitle; private String m_dlgTitleStr; private String[] m_texts; - private CommonPrefs m_cp; + private boolean m_firingPrefs; private JNIUtils m_jniu; private boolean m_volKeysZoom; @@ -225,7 +225,6 @@ public class BoardActivity extends Activity implements UtilCtxt { { super.onCreate( savedInstanceState ); - m_cp = CommonPrefs.get(); m_jniu = JNIUtilsImpl.get(); m_volKeysZoom = CommonPrefs.getVolKeysZoom(); setContentView( R.layout.board ); @@ -271,7 +270,7 @@ public class BoardActivity extends Activity implements UtilCtxt { if ( null != m_jniThread ) { m_jniThread.waitToStop(); m_jniThread = null; - Utils.logf( "onStop(): waitToStop() returned" ); + Utils.logf( "onPause(): waitToStop() returned" ); } // This has to happen after the drawing thread is killed @@ -293,7 +292,8 @@ public class BoardActivity extends Activity implements UtilCtxt { { super.onWindowFocusChanged( hasFocus ); if ( hasFocus ) { - if ( null == m_cp ) { + if ( m_firingPrefs ) { + m_firingPrefs = false; m_view.prefsChanged(); m_jniThread.handle( JNIThread.JNICmd.CMD_PREFS_CHANGE ); } @@ -412,7 +412,7 @@ public class BoardActivity extends Activity implements UtilCtxt { m_jniThread.handle( JNIThread.JNICmd.CMD_RESEND ); break; case R.id.board_menu_file_prefs: - m_cp = null; // mark so we'll reset it later + m_firingPrefs = true; startActivity( new Intent( this, PrefsActivity.class ) ); break; case R.id.board_menu_file_about: @@ -567,13 +567,14 @@ public class BoardActivity extends Activity implements UtilCtxt { m_gi.serverRole ); } + CommonPrefs cp = CommonPrefs.get(); if ( null == stream || ! XwJNI.game_makeFromStream( m_jniGamePtr, stream, m_gi, dictBytes, this, - m_jniu, m_view, m_cp, + m_jniu, m_view, cp, m_xport ) ) { XwJNI.game_makeNewGame( m_jniGamePtr, m_gi, this, m_jniu, - m_view, m_cp, m_xport, dictBytes ); + m_view, cp, m_xport, dictBytes ); } m_jniThread = new