in debug builds track who sets env so we can log who has it on

conflict rather than just assert.
This commit is contained in:
eehouse 2010-03-21 03:10:10 +00:00
parent 62b586d322
commit b6aaf6c38c

View file

@ -265,16 +265,32 @@ typedef struct _JNIState {
XWGame game;
JNIEnv* env;
AndGlobals globals;
#ifdef DEBUG
const char* envSetterFunc;
#endif
MPSLOT
} JNIState;
#ifdef DEBUG
# define CHECK_ENV() \
if ( state->env != 0 && state->env != env ) { \
XP_LOGF( "ERROR: %s trying to set env when %s still has it", \
__func__, state->envSetterFunc ); \
XP_ASSERT( state->env == 0 || state->env == env ); \
} \
state->envSetterFunc = __func__; \
#else
# define CHECK_ENV()
#endif
#define XWJNI_START() { \
XP_ASSERT( 0 != gamePtr ); \
JNIState* state = (JNIState*)gamePtr; \
MPSLOT; \
MPASSIGN( mpool, state->mpool); \
/* if reentrant must be from same thread */ \
XP_ASSERT( state->env == 0 || state->env == env ); \
CHECK_ENV(); \
JNIEnv* _oldEnv = state->env; \
state->env = env;