fix to not crash, and exit cleanly, when opening unopenable games

When e.g. I open a game saved with a newer stream version flag it as
bad rather than asserting each time.
This commit is contained in:
Eric House 2022-11-04 17:41:40 -07:00
parent e7861dca48
commit 93e6e315db
2 changed files with 10 additions and 16 deletions

View file

@ -101,6 +101,7 @@ public class Quarantine {
store(); store();
Log.d( TAG, "markBad(%d): %s", rowid, sDataRef[0].toString() ); Log.d( TAG, "markBad(%d): %s", rowid, sDataRef[0].toString() );
} }
GameListItem.inval( rowid );
} }
private static class QData implements Serializable { private static class QData implements Serializable {

View file

@ -37,6 +37,7 @@ import org.eehouse.android.xw4.DupeModeTimer;
import org.eehouse.android.xw4.GameLock; import org.eehouse.android.xw4.GameLock;
import org.eehouse.android.xw4.GameUtils; import org.eehouse.android.xw4.GameUtils;
import org.eehouse.android.xw4.Log; import org.eehouse.android.xw4.Log;
import org.eehouse.android.xw4.Quarantine;
import org.eehouse.android.xw4.R; import org.eehouse.android.xw4.R;
import org.eehouse.android.xw4.Utils; import org.eehouse.android.xw4.Utils;
import org.eehouse.android.xw4.XWPrefs; import org.eehouse.android.xw4.XWPrefs;
@ -234,25 +235,16 @@ public class JNIThread extends Thread implements AutoCloseable {
utils, null, cp, m_xport ); utils, null, cp, m_xport );
} }
if ( null == m_jniGamePtr ) { if ( null == m_jniGamePtr ) {
// I don't think games get created here. If they do, I Quarantine.markBad( m_rowid );
// need to get the selfAddr from somewhere other than success = false;
// generic defaults, as the user should have configured an } else {
// address for the game.
Assert.assertTrueNR( m_gi.serverRole != DeviceRole.SERVER_ISCLIENT );
Assert.failDbg(); // Do I ever get here????
CommsAddrRec selfAddr = CommsAddrRec.getSelfAddr( context, m_gi );
CommsAddrRec hostAddr = null;
m_jniGamePtr = XwJNI.initNew( m_gi, selfAddr, hostAddr,
utils, null, cp, m_xport );
}
Assert.assertNotNull( m_jniGamePtr );
notifyAll(); notifyAll();
}
m_lastSavedState = Arrays.hashCode( stream ); m_lastSavedState = Arrays.hashCode( stream );
DupeModeTimer.gameOpened( m_context, m_rowid ); DupeModeTimer.gameOpened( m_context, m_rowid );
} }
}
}
Log.d( TAG, "configure() => %b", success ); Log.d( TAG, "configure() => %b", success );
return success; return success;
} }
@ -274,6 +266,7 @@ public class JNIThread extends Thread implements AutoCloseable {
// this thread unless it's doing something interruptable // this thread unless it's doing something interruptable
// (like blocking on a socket) so might as well let it // (like blocking on a socket) so might as well let it
// take however log it takes. If that's too long, fix it. // take however log it takes. If that's too long, fix it.
interrupt();
join(); join();
// Assert.assertFalse( isAlive() ); // Assert.assertFalse( isAlive() );
} catch ( java.lang.InterruptedException ie ) { } catch ( java.lang.InterruptedException ie ) {