save game and summary in a synchronized block so lock doesn't get released halfway through

This commit is contained in:
Eric House 2014-02-24 21:50:17 -08:00
parent 27a5990283
commit fc799449e9

View file

@ -325,12 +325,15 @@ public class JNIThread extends Thread {
if ( Arrays.equals( m_gameAtStart, state ) ) { if ( Arrays.equals( m_gameAtStart, state ) ) {
// DbgUtils.logf( "no change in game; can skip saving" ); // DbgUtils.logf( "no change in game; can skip saving" );
} else { } else {
GameSummary summary = new GameSummary( m_context, m_gi ); synchronized( this ) {
XwJNI.game_summarize( m_jniGamePtr, summary ); Assert.assertNotNull( m_lock );
DBUtils.saveGame( m_context, m_lock, state, false ); GameSummary summary = new GameSummary( m_context, m_gi );
DBUtils.saveSummary( m_context, m_lock, summary ); XwJNI.game_summarize( m_jniGamePtr, summary );
// There'd better be no way for saveGame above to fail! DBUtils.saveGame( m_context, m_lock, state, false );
XwJNI.game_saveSucceeded( m_jniGamePtr ); DBUtils.saveSummary( m_context, m_lock, summary );
// There'd better be no way for saveGame above to fail!
XwJNI.game_saveSucceeded( m_jniGamePtr );
}
} }
} }