hack around IllegalStateException with Wait alert

The pesky thing is back. When app's in the background with an
unconnected game open displaying the "resend/wait" alert and the game
connects get IllegalStateException because the fragment stack's being
modified after onSaveInstanceState() (or, because the dialog fragment,
saved as an instance variable in BoardDelegate, dates from an earlier
state. Anyway, catching and dropping the exception and elsewhere failing
silently to rebuild the alert seems to fix the problem, but the right
fix is likely different. I suspect hanging onto that iVar is wrong, and
that the dialog should go away when onStop() is called and then be
rebuilt later from saved state. But for now, not crashing is good.
This commit is contained in:
Eric House 2018-03-21 08:11:07 -07:00
parent fef4db0ee4
commit ab0764fa5a
2 changed files with 2 additions and 4 deletions

View file

@ -2240,9 +2240,8 @@ public class BoardDelegate extends DelegateBase
// see....
try {
m_inviteAlert.dismiss();
} catch ( NullPointerException npe ) {
Log.ex( TAG, npe );
// Assert.assertFalse( BuildConfig.DEBUG );
} catch ( NullPointerException | IllegalStateException ex ) {
Log.ex( TAG, ex );
}
m_inviteAlert = null;
m_haveStartedShowing = false;

View file

@ -55,7 +55,6 @@ abstract class XWDialogFragment extends DialogFragment {
if ( null != m_buttonMap ) {
AlertDialog dialog = (AlertDialog)getDialog();
Assert.assertTrue( null != dialog || !BuildConfig.DEBUG );
if ( null != dialog) {
for ( final int but : m_buttonMap.keySet() ) {
// final int fbut = but;