From 8947ddca0b9121ab5e334edaf892948d595ad960 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 5 Feb 2012 19:11:38 -0800 Subject: [PATCH] on ICS CreateGlobalRef doesn't return the same value as is passed in. So stop assuming it does! Fixes multiple crashes on ICS and need to be ported to android_branch. --- xwords4/android/XWords4/jni/anddict.c | 2 +- xwords4/android/XWords4/jni/drawwrapper.c | 6 +++--- xwords4/android/XWords4/jni/xportwrapper.c | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/xwords4/android/XWords4/jni/anddict.c b/xwords4/android/XWords4/jni/anddict.c index 2f986efd2..a8ce5b419 100644 --- a/xwords4/android/XWords4/jni/anddict.c +++ b/xwords4/android/XWords4/jni/anddict.c @@ -140,8 +140,8 @@ andMakeBitmap( AndDictionaryCtxt* ctxt, XP_U8 const** ptrp, JNIEnv* env = ctxt->env; bitmap = and_util_makeJBitmap( ctxt->jniutil, nCols, nRows, colors ); - (void)(*env)->NewGlobalRef( env, bitmap ); (*env)->DeleteLocalRef( env, bitmap ); + bitmap = (*env)->NewGlobalRef( env, bitmap ); XP_FREE( ctxt->super.mpool, colors ); #endif } diff --git a/xwords4/android/XWords4/jni/drawwrapper.c b/xwords4/android/XWords4/jni/drawwrapper.c index ac62259b3..e9e449c8e 100644 --- a/xwords4/android/XWords4/jni/drawwrapper.c +++ b/xwords4/android/XWords4/jni/drawwrapper.c @@ -54,10 +54,10 @@ makeJRect( AndDraw* draw, int indx, const XP_Rect* rect ) right, bottom ); (*env)->DeleteLocalRef( env, rclass ); - draw->jCache[indx] = robj; - robj = (*env)->NewGlobalRef( env, robj ); (*env)->DeleteLocalRef( env, robj ); + robj = (*env)->NewGlobalRef( env, robj ); + draw->jCache[indx] = robj; } else { setInt( env, robj, "left", rect->left ); setInt( env, robj, "top", rect->top ); @@ -81,8 +81,8 @@ makeDSI( AndDraw* draw, int indx, const DrawScoreInfo* dsi ) dsiobj = (*env)->NewObject( env, rclass, initId ); (*env)->DeleteLocalRef( env, rclass ); - dsiobj = (*env)->NewGlobalRef( env, dsiobj ); (*env)->DeleteLocalRef( env, dsiobj ); + dsiobj = (*env)->NewGlobalRef( env, dsiobj ); draw->jCache[indx] = dsiobj; } diff --git a/xwords4/android/XWords4/jni/xportwrapper.c b/xwords4/android/XWords4/jni/xportwrapper.c index b5050fbe5..16375adb3 100644 --- a/xwords4/android/XWords4/jni/xportwrapper.c +++ b/xwords4/android/XWords4/jni/xportwrapper.c @@ -177,7 +177,6 @@ makeXportProcs( MPFORMAL JNIEnv** envp, jobject jxport ) if ( NULL != jxport ) { aprocs->jxport = (*env)->NewGlobalRef( env, jxport ); } - XP_ASSERT( aprocs->jxport == jxport ); aprocs->envp = envp; MPASSIGN( aprocs->mpool, mpool );