Merge pull request #886 from minggo/merge_iss1216

Merge iss1216
This commit is contained in:
minggo 2012-05-03 01:34:40 -07:00
commit fc4937541e
4 changed files with 10 additions and 20 deletions

View File

@ -60,13 +60,9 @@ extern "C"
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInsertText(JNIEnv* env, jobject thiz, jstring text) void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInsertText(JNIEnv* env, jobject thiz, jstring text)
{ {
jboolean isCopy = 0; const char* pszText = env->GetStringUTFChars(text, NULL);
const char* pszText = env->GetStringUTFChars(text, &isCopy); cocos2d::CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(pszText, strlen(pszText));
if (isCopy) env->ReleaseStringUTFChars(text, pszText);
{
cocos2d::CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(pszText, strlen(pszText));
env->ReleaseStringUTFChars(text, pszText);
}
} }
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeDeleteBackward(JNIEnv* env, jobject thiz) void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeDeleteBackward(JNIEnv* env, jobject thiz)

View File

@ -161,18 +161,14 @@ extern "C"
{ {
JNIEnv *env = 0; JNIEnv *env = 0;
jboolean isCopy;
if (! getEnv(&env)) if (! getEnv(&env))
{ {
return 0; return 0;
} }
const char* chars = env->GetStringUTFChars(jstr, &isCopy); const char* chars = env->GetStringUTFChars(jstr, NULL);
string ret(chars); string ret(chars);
if (isCopy) env->ReleaseStringUTFChars(jstr, chars);
{
env->ReleaseStringUTFChars(jstr, chars);
}
return ret; return ret;
} }

View File

@ -123,12 +123,8 @@ extern "C"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void Java_org_cocos2dx_lib_Cocos2dxActivity_nativeSetPaths(JNIEnv* env, jobject thiz, jstring apkPath) void Java_org_cocos2dx_lib_Cocos2dxActivity_nativeSetPaths(JNIEnv* env, jobject thiz, jstring apkPath)
{ {
const char* str; const char* str = env->GetStringUTFChars(apkPath, NULL);
jboolean isCopy; cocos2d::CCFileUtils::setResourcePath(str);
str = env->GetStringUTFChars(apkPath, &isCopy); env->ReleaseStringUTFChars(apkPath, str);
if (isCopy) {
cocos2d::CCFileUtils::setResourcePath(str);
env->ReleaseStringUTFChars(apkPath, str);
}
} }
} }

View File

@ -53,6 +53,7 @@ extern "C"
t.env->DeleteLocalRef(t.classID); t.env->DeleteLocalRef(t.classID);
CCString *ret = new CCString(JniHelper::jstring2string(str).c_str()); CCString *ret = new CCString(JniHelper::jstring2string(str).c_str());
ret->autorelease(); ret->autorelease();
t.env->DeleteLocalRef(str);
LOGD("package name %s", ret->m_sString.c_str()); LOGD("package name %s", ret->m_sString.c_str());
@ -78,6 +79,7 @@ extern "C"
t.env->DeleteLocalRef(t.classID); t.env->DeleteLocalRef(t.classID);
CCString *ret = new CCString(JniHelper::jstring2string(str).c_str()); CCString *ret = new CCString(JniHelper::jstring2string(str).c_str());
ret->autorelease(); ret->autorelease();
t.env->DeleteLocalRef(str);
LOGD("language name %s", ret.c_str()); LOGD("language name %s", ret.c_str());