[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[core] release char* to jni after using (#1612)
Browse files Browse the repository at this point in the history
  • Loading branch information
yxping authored and YorkShen committed Oct 2, 2018
1 parent 77b00ac commit a4efea0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions weex_core/Source/android/base/string/string_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ static inline std::string jString2Str(JNIEnv *env, const jstring &jstr) {
static inline std::string jString2StrFast(JNIEnv *env, const jstring &jstr){
if (jstr == nullptr)
return std::string("");
const char *nativeString = env->GetStringUTFChars(jstr, JNI_FALSE);
return std::string(nativeString);
auto nativeString = ScopedJStringUTF8(env, jstr);
return std::string(nativeString.getChars());
}

static std::string jByteArray2Str(JNIEnv *env, jbyteArray barr) {
Expand Down
11 changes: 7 additions & 4 deletions weex_core/Source/android/wrap/wx_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,13 @@ static jlongArray GetRenderFinishTime(JNIEnv* env, jobject jcaller,

// Notice that this method is invoked from main thread.
static jboolean NotifyLayout(JNIEnv* env, jobject jcaller, jstring instanceId) {
return WeexCoreManager::Instance()
->getPlatformBridge()
->core_side()
->NotifyLayout(jString2StrFast(env, instanceId));
if (WeexCoreManager::Instance()->getPlatformBridge()) {
return WeexCoreManager::Instance()
->getPlatformBridge()
->core_side()
->NotifyLayout(jString2StrFast(env, instanceId));
}
return false;
}

// Notice that this method is invoked from JS thread.
Expand Down

0 comments on commit a4efea0

Please sign in to comment.