mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-06 05:24:46 +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 )
|
public static long dupeGame( Context context, long rowidIn )
|
||||||
{
|
{
|
||||||
long rowid = DBUtils.ROWID_NOTFOUND;
|
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 ) {
|
if ( null != lockSrc ) {
|
||||||
boolean juggle = CommonPrefs.getAutoJuggle( context );
|
boolean juggle = CommonPrefs.getAutoJuggle( context );
|
||||||
GameLock lockDest = resetGame( context, lockSrc, null, juggle );
|
GameLock lockDest = resetGame( context, lockSrc, null, juggle );
|
||||||
rowid = lockDest.getRowid();
|
rowid = lockDest.getRowid();
|
||||||
lockDest.unlock();
|
lockDest.unlock();
|
||||||
lockSrc.unlock();
|
|
||||||
|
if ( null != thread ) {
|
||||||
|
thread.release();
|
||||||
|
} else {
|
||||||
|
lockSrc.unlock();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
DbgUtils.logf( "dupeGame: unable to open rowid %d", rowidIn );
|
DbgUtils.logdf( "dupeGame: unable to open rowid %d", rowidIn );
|
||||||
}
|
}
|
||||||
return rowid;
|
return rowid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1246,8 +1246,10 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
case NEW_FROM:
|
case NEW_FROM:
|
||||||
long curID = (Long)params[0];
|
long curID = (Long)params[0];
|
||||||
long newid = GameUtils.dupeGame( m_activity, curID );
|
long newid = GameUtils.dupeGame( m_activity, curID );
|
||||||
m_selGames.add( newid );
|
if ( DBUtils.ROWID_NOTFOUND != newid ) {
|
||||||
reloadGame( newid );
|
m_selGames.add( newid );
|
||||||
|
reloadGame( newid );
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SET_HIDE_NEWGAME_BUTTONS:
|
case SET_HIDE_NEWGAME_BUTTONS:
|
||||||
|
@ -2130,7 +2132,9 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
long newid;
|
long newid;
|
||||||
if ( null == btAddr && null == phone && null == relayID ) {
|
if ( null == btAddr && null == phone && null == relayID ) {
|
||||||
newid = GameUtils.dupeGame( m_activity, srcRowID );
|
newid = GameUtils.dupeGame( m_activity, srcRowID );
|
||||||
DBUtils.setName( m_activity, newid, gameName );
|
if ( DBUtils.ROWID_NOTFOUND != newid ) {
|
||||||
|
DBUtils.setName( m_activity, newid, gameName );
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
long groupID = DBUtils.getGroupForGame( m_activity, srcRowID );
|
long groupID = DBUtils.getGroupForGame( m_activity, srcRowID );
|
||||||
newid = GameUtils.makeNewMultiGame( m_activity, groupID, dict,
|
newid = GameUtils.makeNewMultiGame( m_activity, groupID, dict,
|
||||||
|
@ -2352,7 +2356,9 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
|
|
||||||
private void launchGame( long rowid, boolean invited )
|
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 );
|
m_launchedGames.add( rowid );
|
||||||
if ( m_adapter.inExpandedGroup( rowid ) ) {
|
if ( m_adapter.inExpandedGroup( rowid ) ) {
|
||||||
setSelGame( rowid );
|
setSelGame( rowid );
|
||||||
|
|
Loading…
Reference in a new issue