mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-07 05:24:46 +01:00
don't crash on null dctxt
This commit is contained in:
parent
88af10552e
commit
3858893ab2
2 changed files with 24 additions and 17 deletions
|
@ -644,21 +644,23 @@ makeDraw( MPFORMAL JNIEnv** envp, jobject jdraw )
|
|||
void
|
||||
destroyDraw( DrawCtx** dctx )
|
||||
{
|
||||
AndDraw* draw = (AndDraw*)*dctx;
|
||||
JNIEnv* env = *draw->env;
|
||||
if ( NULL != draw->jdraw ) {
|
||||
(*env)->DeleteGlobalRef( env, draw->jdraw );
|
||||
}
|
||||
|
||||
int ii;
|
||||
for ( ii = 0; ii < JCACHE_COUNT; ++ii ) {
|
||||
jobject jobj = draw->jCache[ii];
|
||||
if ( !!jobj ) {
|
||||
(*env)->DeleteGlobalRef( env, jobj );
|
||||
if ( !!*dctx ) {
|
||||
AndDraw* draw = (AndDraw*)*dctx;
|
||||
JNIEnv* env = *draw->env;
|
||||
if ( NULL != draw->jdraw ) {
|
||||
(*env)->DeleteGlobalRef( env, draw->jdraw );
|
||||
}
|
||||
}
|
||||
|
||||
XP_FREE( draw->mpool, draw->vtable );
|
||||
XP_FREE( draw->mpool, draw );
|
||||
*dctx = NULL;
|
||||
int ii;
|
||||
for ( ii = 0; ii < JCACHE_COUNT; ++ii ) {
|
||||
jobject jobj = draw->jCache[ii];
|
||||
if ( !!jobj ) {
|
||||
(*env)->DeleteGlobalRef( env, jobj );
|
||||
}
|
||||
}
|
||||
|
||||
XP_FREE( draw->mpool, draw->vtable );
|
||||
XP_FREE( draw->mpool, draw );
|
||||
*dctx = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -417,7 +417,10 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeNewGame
|
|||
globals->util = makeUtil( MPPARM(mpool) &state->env, j_util, gi,
|
||||
globals );
|
||||
globals->jniutil = makeJNIUtil( MPPARM(mpool) &state->env, jniu );
|
||||
DrawCtx* dctx = makeDraw( MPPARM(mpool) &state->env, j_draw );
|
||||
DrawCtx* dctx = NULL;
|
||||
if ( !!j_draw ) {
|
||||
dctx = makeDraw( MPPARM(mpool) &state->env, j_draw );
|
||||
}
|
||||
globals->dctx = dctx;
|
||||
globals->xportProcs = makeXportProcs( MPPARM(mpool) &state->env, j_procs );
|
||||
CommonPrefs cp;
|
||||
|
@ -486,7 +489,9 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeFromStream
|
|||
globals->jniutil = makeJNIUtil( MPPARM(mpool) &state->env, jniu );
|
||||
makeDicts( MPPARM(mpool) env, globals->jniutil, &dict, &dicts, jdictNames,
|
||||
jdicts, jpaths, jlang );
|
||||
globals->dctx = makeDraw( MPPARM(mpool) &state->env, jdraw );
|
||||
if ( !!jdraw ) {
|
||||
globals->dctx = makeDraw( MPPARM(mpool) &state->env, jdraw );
|
||||
}
|
||||
globals->xportProcs = makeXportProcs( MPPARM(mpool) &state->env, jprocs );
|
||||
|
||||
XWStreamCtxt* stream = streamFromJStream( MPPARM(mpool) env,
|
||||
|
|
Loading…
Reference in a new issue