mirror of https://github.com/axmolengine/axmol.git
Fixed non-functioning default value for CCUserDefault::getDoubleForKey()
- defaultValue was not being passed into the JNI CallStaticDoubleMethod method previously. - CCUserDefault::getDoubleForKey() would return undefined garbage when the key doesn’t exist. Test Case: Call the following from anywhere in your code (in release configuration). X will be garbage. Call the following from your code: double x = CCUserDefault::sharedUserDefault()->getDoubleForKey("Some-Non-existant-k ey-1234", 0); CCLOG("x = %4.2f", x); Fix Tested on Android. Affects Android only.
This commit is contained in:
parent
92dba007c7
commit
52c66a678c
|
@ -190,7 +190,7 @@ double getDoubleForKeyJNI(const char* pKey, double defaultValue)
|
|||
|
||||
if (JniHelper::getStaticMethodInfo(t, CLASS_NAME, "getDoubleForKey", "(Ljava/lang/String;D)D")) {
|
||||
jstring stringArg = t.env->NewStringUTF(pKey);
|
||||
jdouble ret = t.env->CallStaticDoubleMethod(t.classID, t.methodID, stringArg);
|
||||
jdouble ret = t.env->CallStaticDoubleMethod(t.classID, t.methodID, stringArg, defaultValue);
|
||||
|
||||
t.env->DeleteLocalRef(t.classID);
|
||||
t.env->DeleteLocalRef(stringArg);
|
||||
|
|
Loading…
Reference in New Issue