Skip to content

Commit

Permalink
修复Android平台下map中设置null元素转换失败问题
Browse files Browse the repository at this point in the history
  • Loading branch information
vimfung committed Aug 7, 2018
1 parent 86fb137 commit cb43ed8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ LuaValue* LuaJavaConverter::convertToLuaValueByJObject(JNIEnv *env, LuaContext *
{
LuaValue *value = NULL;

if (env -> IsInstanceOf(object, LuaJavaType::stringClass(env)) == JNI_TRUE)
if (env -> IsSameObject(object, NULL) == JNI_TRUE)
{
value = LuaValue::NilValue();
}
else if (env -> IsInstanceOf(object, LuaJavaType::stringClass(env)) == JNI_TRUE)
{
//String类型
jstring str = (jstring) object;
Expand Down
2 changes: 1 addition & 1 deletion Source/Android/luascriptcore/src/main/jni/LuaJavaEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ LuaObjectDescriptor* LuaJavaEnv::getAssociateInstanceRef(JNIEnv *env, jobject in
{
LuaObjectDescriptor *objectDescriptor = NULL;

if (env -> IsInstanceOf(instance, LuaJavaType::luaBaseObjectClass(env)) == JNI_TRUE)
if (instance != NULL && env -> IsInstanceOf(instance, LuaJavaType::luaBaseObjectClass(env)) == JNI_TRUE)
{
jfieldID nativeFieldId = env -> GetFieldID(env -> GetObjectClass(instance), "_nativeId", "I");
jint nativeId = env -> GetIntField(instance, nativeFieldId);
Expand Down

0 comments on commit cb43ed8

Please sign in to comment.