Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: jni/JniUpdateAvailableCallback.cpp

Issue 4761138508070912: Issue 1848 - Clean up local reference handling (Closed)
Patch Set: Removed member variable prefixes Created Jan. 23, 2015, 1:16 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: jni/JniUpdateAvailableCallback.cpp
diff --git a/jni/JniUpdateAvailableCallback.cpp b/jni/JniUpdateAvailableCallback.cpp
index d8a4b2181e7dc96917137787029bc67bd3eb692e..8246eb64d8a33377e0572be1be199726b7e496a2 100644
--- a/jni/JniUpdateAvailableCallback.cpp
+++ b/jni/JniUpdateAvailableCallback.cpp
@@ -41,14 +41,15 @@ void JniUpdateAvailableCallback::Callback(const std::string& arg)
{
JNIEnvAcquire env(GetJavaVM());
- jclass clazz = env->GetObjectClass(GetCallbackObject());
- jmethodID method = env->GetMethodID(clazz, "updateAvailableCallback",
- "(Ljava/lang/String;)V");
+ jmethodID method = env->GetMethodID(
+ *JniLocalReference<jclass>(*env,
+ env->GetObjectClass(GetCallbackObject())), "updateAvailableCallback",
Felix Dahlke 2015/02/03 05:22:50 Just my opinion, but I'd find this easier to read
René Jeschke 2015/02/03 13:51:26 Done.
+ "(Ljava/lang/String;)V");
if (method)
{
- jstring jArg = env->NewStringUTF(arg.c_str());
- env->CallVoidMethod(GetCallbackObject(), method, jArg);
+ JniLocalReference<jstring> jArg(*env, env->NewStringUTF(arg.c_str()));
+ env->CallVoidMethod(GetCallbackObject(), method, *jArg);
}
CheckAndLogJavaException(*env);

Powered by Google App Engine
This is Rietveld