mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
don't dispose gi before game
gathering players was failing because disposed gi was pointing at garbage. I'm lucky it didn't segfault.
This commit is contained in:
parent
e7a63c7c0b
commit
5d4fd0e58b
7 changed files with 22 additions and 12 deletions
|
@ -316,6 +316,7 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba
|
|||
params.put( "myNow", now );
|
||||
params.put( "loc", LocUtils.getCurLocale( mContext ) );
|
||||
params.put( "tmpKey", getTmpKey(mContext) );
|
||||
params.put( "frstV", Utils.getFirstVersion( mContext ) );
|
||||
|
||||
String fcmid = FBMService.getFCMDevID( mContext );
|
||||
if ( null != fcmid ) {
|
||||
|
|
|
@ -799,6 +799,16 @@ public class Utils {
|
|||
}
|
||||
}
|
||||
|
||||
static int getFirstVersion( Context context )
|
||||
{
|
||||
SharedPreferences prefs =
|
||||
context.getSharedPreferences( HIDDEN_PREFS,
|
||||
Context.MODE_PRIVATE );
|
||||
int firstVersion = prefs.getInt( FIRST_VERSION_KEY, Integer.MAX_VALUE );
|
||||
Assert.assertTrueNR( firstVersion < Integer.MAX_VALUE );
|
||||
return firstVersion;
|
||||
}
|
||||
|
||||
private static void setFirstBootStatics( Context context )
|
||||
{
|
||||
if ( null == s_isFirstBootThisVersion ) {
|
||||
|
|
|
@ -882,8 +882,8 @@ Java_org_eehouse_android_xw4_jni_XwJNI_gi_1from_1stream
|
|||
XWStreamCtxt* stream = streamFromJStream( MPPARM(mpool) env,
|
||||
globalState->vtMgr, jstream );
|
||||
|
||||
CurGameInfo gi;
|
||||
XP_MEMSET( &gi, 0, sizeof(gi) );
|
||||
CurGameInfo gi = {0};
|
||||
// XP_MEMSET( &gi, 0, sizeof(gi) );
|
||||
if ( game_makeFromStream( MPPARM(mpool) env, stream, NULL,
|
||||
&gi, NULL, NULL, NULL, NULL, NULL, NULL ) ) {
|
||||
setJGI( env, jgi, &gi );
|
||||
|
@ -910,7 +910,6 @@ Java_org_eehouse_android_xw4_jni_XwJNI_nli_1to_1stream
|
|||
jbyteArray result;
|
||||
NetLaunchInfo nli = {0};
|
||||
loadNLI( env, &nli, jnli );
|
||||
/* CurGameInfo* gi = makeGI( MPPARM(mpool) env, jgi ); */
|
||||
XWStreamCtxt* stream = mem_stream_make( MPPARM(mpool) globalState->vtMgr,
|
||||
NULL, 0, NULL );
|
||||
|
||||
|
@ -1412,9 +1411,9 @@ JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_game_1dispose
|
|||
#endif
|
||||
AndGameGlobals* globals = &state->globals;
|
||||
|
||||
destroyGI( MPPARM(mpool) &globals->gi );
|
||||
|
||||
game_dispose( &state->game, env );
|
||||
/* Must happen after game_dispose, which uses it */
|
||||
destroyGI( MPPARM(mpool) &globals->gi );
|
||||
|
||||
destroyDraw( &globals->dctx, env );
|
||||
destroyXportProcs( &globals->xportProcs, env );
|
||||
|
|
|
@ -879,7 +879,7 @@ board_canHint( const BoardCtxt* board )
|
|||
&& 0 < model_getNumTilesTotal( board->model, board->selPlayer )
|
||||
&& ! board->pti[board->selPlayer].tradeInProgress;
|
||||
if ( canHint ) {
|
||||
LocalPlayer* lp = &board->gi->players[board->selPlayer];
|
||||
const LocalPlayer* lp = &board->gi->players[board->selPlayer];
|
||||
canHint = lp->isLocal && !LP_IS_ROBOT(lp);
|
||||
}
|
||||
return canHint;
|
||||
|
|
|
@ -1650,7 +1650,7 @@ resendImpl( CommsCtxt* comms, XWEnv xwe, CommsConnType filter, XP_Bool force,
|
|||
|
||||
XP_U32 now = dutil_getCurSeconds( comms->dutil, xwe );
|
||||
if ( !force && (now < comms->nextResend) ) {
|
||||
XP_LOGF( "%s: aborting: %d seconds left in backoff", __func__,
|
||||
XP_LOGFF( "aborting: %d seconds left in backoff",
|
||||
comms->nextResend - now );
|
||||
success = XP_FALSE;
|
||||
|
||||
|
@ -1868,7 +1868,7 @@ relayPreProcess( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream, XWHostID* se
|
|||
|
||||
/* nothing for us to do here if not using relay */
|
||||
XWRELAY_Cmd cmd = stream_getU8( stream );
|
||||
XP_LOGF( "%s(%s)", __func__, relayCmdToStr( cmd ) );
|
||||
XP_LOGFF( "(%s)", relayCmdToStr( cmd ) );
|
||||
switch( cmd ) {
|
||||
|
||||
case XWRELAY_CONNECT_RESP:
|
||||
|
@ -2017,7 +2017,7 @@ relayPreProcess( CommsCtxt* comms, XWEnv xwe, XWStreamCtxt* stream, XWHostID* se
|
|||
XP_LOGF( "%s: dropping relay msg with cmd %d", __func__, (XP_U16)cmd );
|
||||
}
|
||||
|
||||
LOG_RETURNF( "%s", boolToStr(consumed) );
|
||||
LOG_RETURNF( "consumed=%s", boolToStr(consumed) );
|
||||
return consumed;
|
||||
} /* relayPreProcess */
|
||||
#endif
|
||||
|
@ -2065,7 +2065,7 @@ preProcess( CommsCtxt* comms, XWEnv xwe, const CommsAddrRec* useAddr,
|
|||
|
||||
/* There should be exactly one type associated with an incoming message */
|
||||
CommsConnType typ = addr_getType( useAddr );
|
||||
XP_LOGF( "%s(typ=%s)", __func__, ConnType2Str(typ) );
|
||||
XP_LOGFF( "(typ=%s)", ConnType2Str(typ) );
|
||||
|
||||
switch ( typ ) {
|
||||
#ifdef XWFEATURE_RELAY
|
||||
|
@ -2611,6 +2611,7 @@ comms_gatherPlayers( CommsCtxt* comms, XWEnv xwe, XP_U32 created )
|
|||
comms_getAddrs( comms, NULL, addrs, &nRecs );
|
||||
|
||||
const CurGameInfo* gi = comms->util->gameInfo;
|
||||
XP_ASSERT( 0 < gi->nPlayers );
|
||||
if ( kplr_addAddrs( comms->dutil, xwe, gi, addrs, nRecs, created ) ) {
|
||||
if ( 1 ) {
|
||||
XP_LOGFF( "not setting flag :-)" );
|
||||
|
|
|
@ -117,7 +117,6 @@ static const XP_UCHAR*
|
|||
figureNameFor( XP_U16 posn, const CurGameInfo* gi )
|
||||
{
|
||||
const XP_UCHAR* result = NULL;
|
||||
// int nthRemote = 0;
|
||||
for ( int ii = 0, nthRemote = 0;
|
||||
NULL == result && ii < gi->nPlayers;
|
||||
++ii ) {
|
||||
|
|
|
@ -247,7 +247,7 @@ drawScoreBoard( BoardCtxt* board, XWEnv xwe )
|
|||
totalDim = 0;
|
||||
XP_U16 missingPlayers = server_getMissingPlayers( board->server );
|
||||
for ( dp = datum, ii = 0; ii < nPlayers; ++ii, ++dp ) {
|
||||
LocalPlayer* lp = &board->gi->players[ii];
|
||||
const LocalPlayer* lp = &board->gi->players[ii];
|
||||
XP_Bool isMissing = 0 != ((1 << ii) & missingPlayers);
|
||||
|
||||
/* This is a hack! */
|
||||
|
|
Loading…
Reference in a new issue