在cocos2dx字典转换nactive的函数jsval_to_ccdictionary,只判断三个类型如果为空导致系统崩溃
以下是修改方法:找到函数底部
else if (JSVAL_IS_STRING(value)) {
JSStringWrapper valueWapper(JSVAL_TO_STRING(value), cx);
dict->setObject(String::create(valueWapper.get()), keyWrapper.get());
// CCLOG("iterate object: key = %s, value = %s", keyWrapper.get().c_str(), valueWapper.get().c_str());
}
else if (JSVAL_IS_NUMBER(value)) {
double number = 0.0;
JSBool ok = JS_ValueToNumber(cx, value, &number);
if (ok) {
dict->setObject(Double::create(number), keyWrapper.get());
// CCLOG("iterate object: key = %s, value = %lf", keyWrapper.get().c_str(), number);
}
}
else if (JSVAL_IS_BOOLEAN(value)) {
JSBool boolVal = JS_FALSE;
JSBool ok = JS_ValueToBoolean(cx, value, &boolVal);
if (ok) {
dict->setObject(Bool::create(boolVal), keyWrapper.get());
// +CCLOG("iterate object: key = %s, value = %d", keyWrapper.get().c_str(), boolVal);
}
}else if (value.isNullOrUndefined())
{
// CCASSERT(false, "not isNull supported type");//value.isNullOrUndefined 这个需要判断,插入为空的值系统崩溃。
dict->setObject(String::create(""), keyWrapper.get());
}
else {
CCASSERT(false, "not supported type");
}