mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-20 22:26:54 +01:00
Handle case where we want to open a game that's already open (likely
in the process of being closed.) If we're successful in getting a JNIThread object that's already initialized, re-use it, closing only the JNI part (which probably can't be cleanly re-used with a different Context.) I worry about the case where the thread's event queue isn't empty, so there's an assert to catch that case.
This commit is contained in:
parent
79efbd2076
commit
80ebcff4c9
2 changed files with 24 additions and 14 deletions
|
@ -1967,7 +1967,13 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
private void startFirstHasDict( long rowid )
|
||||
{
|
||||
if ( -1 != rowid && DBUtils.haveGame( m_activity, rowid ) ) {
|
||||
if ( GameUtils.gameDictsHere( m_activity, rowid ) ) {
|
||||
boolean haveDict;
|
||||
try {
|
||||
haveDict = GameUtils.gameDictsHere( m_activity, rowid );
|
||||
} catch ( GameLock.GameLockedException gle ) {
|
||||
haveDict = true;
|
||||
}
|
||||
if ( haveDict ) {
|
||||
launchGame( rowid );
|
||||
}
|
||||
}
|
||||
|
@ -2321,18 +2327,12 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
|
||||
private void tryStartsFromIntent( Intent intent )
|
||||
{
|
||||
try {
|
||||
startFirstHasDict( intent );
|
||||
startNewNetGame( intent );
|
||||
startHasGameID( intent );
|
||||
startRematch( intent );
|
||||
tryAlert( intent );
|
||||
tryNFCIntent( intent );
|
||||
} catch ( GameLock.GameLockedException gle ) {
|
||||
DbgUtils.loge( gle );
|
||||
showToast( "Finishing; game already open" ); // FIX ME!!!
|
||||
finish();
|
||||
}
|
||||
startFirstHasDict( intent );
|
||||
startNewNetGame( intent );
|
||||
startHasGameID( intent );
|
||||
startRematch( intent );
|
||||
tryAlert( intent );
|
||||
tryNFCIntent( intent );
|
||||
}
|
||||
|
||||
private void doOpenGame( Object[] params )
|
||||
|
|
|
@ -195,8 +195,18 @@ public class JNIThread extends Thread {
|
|||
m_context = context;
|
||||
m_drawer = drawer;
|
||||
m_handler = handler;
|
||||
|
||||
if ( null == m_lock ) {
|
||||
m_lock = new GameLock( m_rowid, true ).lock();
|
||||
} else {
|
||||
m_jniGamePtr.release(); // let the old game copy go
|
||||
}
|
||||
|
||||
// If this isn't true then the queue has to be allowed to empty,
|
||||
// working on the old game state, before we can re-use any of this.
|
||||
Assert.assertTrue( 0 == m_queue.size() );
|
||||
|
||||
m_jniGamePtr = XwJNI.initJNI( m_rowid );
|
||||
m_lock = new GameLock( m_rowid, true ).lock();
|
||||
|
||||
String[] dictNames = GameUtils.dictNames( context, m_lock );
|
||||
DictUtils.DictPairs pairs = DictUtils.openDicts( context, dictNames );
|
||||
|
|
Loading…
Reference in a new issue