fix NPE in race; no longer any need to set preferred orientation; do a

bit of asserting trying to catch another race.
This commit is contained in:
Eric House 2011-03-14 18:34:00 -07:00
parent 58cb40b08e
commit bcf767d66e

View file

@ -77,7 +77,6 @@ public class BoardActivity extends XWActivity
private TimerRunnable[] m_timers; private TimerRunnable[] m_timers;
private String m_path; private String m_path;
private Uri m_uri; private Uri m_uri;
private int m_currentOrient;
private Toolbar m_toolbar; private Toolbar m_toolbar;
private ArrayList<String> m_pendingChats = new ArrayList<String>(); private ArrayList<String> m_pendingChats = new ArrayList<String>();
@ -1119,8 +1118,11 @@ public class BoardActivity extends XWActivity
showDialog( QUERY_ENDGAME ); showDialog( QUERY_ENDGAME );
break; break;
case JNIThread.TOOLBAR_STATES: case JNIThread.TOOLBAR_STATES:
m_gsi = m_jniThread.getGameStateInfo(); if ( null != m_jniThread ) {
updateToolbar(); m_gsi = m_jniThread.getGameStateInfo();
updateToolbar();
}
break;
} }
} }
} ); } );
@ -1233,7 +1235,6 @@ public class BoardActivity extends XWActivity
{ {
return new DialogInterface.OnDismissListener() { return new DialogInterface.OnDismissListener() {
public void onDismiss( DialogInterface di ) { public void onDismiss( DialogInterface di ) {
setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_SENSOR );
releaseIfBlocking(); releaseIfBlocking();
removeDialog( id ); removeDialog( id );
} }
@ -1244,31 +1245,29 @@ public class BoardActivity extends XWActivity
* interrupted before the runnable gets run. In that case there's * interrupted before the runnable gets run. In that case there's
* no dialog to dismiss. So track it. * no dialog to dismiss. So track it.
*/ */
private boolean m_blockingDlgPosted; private boolean m_blockingDlgPosted = false;
private int waitBlockingDialog( final int dlgID, int cancelResult ) private int waitBlockingDialog( final int dlgID, int cancelResult )
{ {
m_blockingDlgPosted = false; Assert.assertFalse( m_blockingDlgPosted );
setBlockingThread(); setBlockingThread();
int orient = m_currentOrient == Configuration.ORIENTATION_LANDSCAPE
? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
: ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
setRequestedOrientation( orient );
m_handler.post( new Runnable() { m_handler.post( new Runnable() {
public void run() { public void run() {
showDialog( dlgID ); showDialog( dlgID ); // crash
m_blockingDlgPosted = true; m_blockingDlgPosted = true;
} }
} ); } );
try { try {
m_forResultWait.acquire(); m_forResultWait.acquire();
m_blockingDlgPosted = false;
} catch ( java.lang.InterruptedException ie ) { } catch ( java.lang.InterruptedException ie ) {
Utils.logf( "waitBlockingDialog: got " + ie.toString() ); Utils.logf( "waitBlockingDialog: got " + ie.toString() );
m_resultCode = cancelResult; m_resultCode = cancelResult;
if ( m_blockingDlgPosted ) { if ( m_blockingDlgPosted ) {
dismissDialog( dlgID ); dismissDialog( dlgID );
m_blockingDlgPosted = false;
} }
} }
clearBlockingThread(); clearBlockingThread();