failing to post a blocking dialog means the jni thread hangs forever.

Bad.  So test if we can post (if the handler's still available) and
drop the request, freeing the thread, if not.  (Access to m_handler
should probably be synchronized now that it's getting cleared, but
that's another bug.)
This commit is contained in:
Andy2 2011-07-29 07:19:33 -07:00
parent 704b08f733
commit 8d9aa5ae0e

View file

@ -1257,25 +1257,27 @@ public class BoardActivity extends XWActivity
Utils.logf( "waitBlockingDialog: dropping dlgID %d", dlgID );
} else {
setBlockingThread();
m_resultCode = cancelResult;
post( new Runnable() {
if ( post( new Runnable() {
public void run() {
showDialog( dlgID );
m_blockingDlgPosted = true;
}
} );
} ) ) {
try {
m_forResultWait.acquire();
m_blockingDlgPosted = false;
} catch ( java.lang.InterruptedException ie ) {
Utils.logf( "waitBlockingDialog: got " + ie.toString() );
m_resultCode = cancelResult;
if ( m_blockingDlgPosted ) {
dismissDialog( dlgID );
try {
m_forResultWait.acquire();
m_blockingDlgPosted = false;
} catch ( java.lang.InterruptedException ie ) {
Utils.logf( "waitBlockingDialog: got %s", ie.toString() );
if ( m_blockingDlgPosted ) {
dismissDialog( dlgID );
m_blockingDlgPosted = false;
}
}
}
clearBlockingThread();
result = m_resultCode;
}
@ -1395,13 +1397,15 @@ public class BoardActivity extends XWActivity
}
}
private void post( Runnable runnable )
private boolean post( Runnable runnable )
{
if ( null != m_handler ) {
boolean canPost = null != m_handler;
if ( canPost ) {
m_handler.post( runnable );
} else {
Utils.logf( "post: dropping because handler null" );
}
return canPost;
}
private void postDelayed( Runnable runnable, int when )