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:
Damien 2013-12-19 12:09:37 -08:00
parent 92dba007c7
commit 52c66a678c
1 changed files with 1 additions and 1 deletions

View File

@ -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);