mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
fix dupeGame for dual-pane case
Current GameLock implementation means you can't get a lock for an open game, so try getting one from an existing JNIThread instance first. Which is a hack that's start to appear in lots of places.... Also fix so just in case we are unable to lock a game we drop the rematch process rather than crash in an assert later. The test case: rematch a solo game that's currently open in the right pane.
This commit is contained in:
parent
16a622d22c
commit
76a7aeb93c
2 changed files with 26 additions and 7 deletions
|
@ -216,15 +216,28 @@ public class GameUtils {
|
|||
public static long dupeGame( Context context, long rowidIn )
|
||||
{
|
||||
long rowid = DBUtils.ROWID_NOTFOUND;
|
||||
GameLock lockSrc = new GameLock( rowidIn, false ).lock( 300 );
|
||||
GameLock lockSrc = null;
|
||||
|
||||
JNIThread thread = JNIThread.getRetained( rowidIn, false );
|
||||
if ( null != thread ) {
|
||||
lockSrc = thread.getLock();
|
||||
} else {
|
||||
lockSrc = new GameLock( rowidIn, false ).lock( 300 );
|
||||
}
|
||||
|
||||
if ( null != lockSrc ) {
|
||||
boolean juggle = CommonPrefs.getAutoJuggle( context );
|
||||
GameLock lockDest = resetGame( context, lockSrc, null, juggle );
|
||||
rowid = lockDest.getRowid();
|
||||
lockDest.unlock();
|
||||
lockSrc.unlock();
|
||||
|
||||
if ( null != thread ) {
|
||||
thread.release();
|
||||
} else {
|
||||
lockSrc.unlock();
|
||||
}
|
||||
} else {
|
||||
DbgUtils.logf( "dupeGame: unable to open rowid %d", rowidIn );
|
||||
DbgUtils.logdf( "dupeGame: unable to open rowid %d", rowidIn );
|
||||
}
|
||||
return rowid;
|
||||
}
|
||||
|
|
|
@ -1246,8 +1246,10 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
case NEW_FROM:
|
||||
long curID = (Long)params[0];
|
||||
long newid = GameUtils.dupeGame( m_activity, curID );
|
||||
m_selGames.add( newid );
|
||||
reloadGame( newid );
|
||||
if ( DBUtils.ROWID_NOTFOUND != newid ) {
|
||||
m_selGames.add( newid );
|
||||
reloadGame( newid );
|
||||
}
|
||||
break;
|
||||
|
||||
case SET_HIDE_NEWGAME_BUTTONS:
|
||||
|
@ -2130,7 +2132,9 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
long newid;
|
||||
if ( null == btAddr && null == phone && null == relayID ) {
|
||||
newid = GameUtils.dupeGame( m_activity, srcRowID );
|
||||
DBUtils.setName( m_activity, newid, gameName );
|
||||
if ( DBUtils.ROWID_NOTFOUND != newid ) {
|
||||
DBUtils.setName( m_activity, newid, gameName );
|
||||
}
|
||||
} else {
|
||||
long groupID = DBUtils.getGroupForGame( m_activity, srcRowID );
|
||||
newid = GameUtils.makeNewMultiGame( m_activity, groupID, dict,
|
||||
|
@ -2352,7 +2356,9 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
|
||||
private void launchGame( long rowid, boolean invited )
|
||||
{
|
||||
if ( ! m_launchedGames.contains( rowid ) ) {
|
||||
if ( DBUtils.ROWID_NOTFOUND == rowid ) {
|
||||
DbgUtils.logdf( "launchGame(): dropping bad rowid" );
|
||||
} else if ( ! m_launchedGames.contains( rowid ) ) {
|
||||
m_launchedGames.add( rowid );
|
||||
if ( m_adapter.inExpandedGroup( rowid ) ) {
|
||||
setSelGame( rowid );
|
||||
|
|
Loading…
Reference in a new issue