From 66f7feda4df7cddd7ad47cada2ce6693955f255e Mon Sep 17 00:00:00 2001 From: Mike Armstrong Date: Wed, 4 Nov 2015 20:31:48 -0800 Subject: [PATCH] Remove NativeRunnables from local references table. Differential Revision: D2620026 fb-gh-sync-id: c105143d3ad932abcaff1407c6434148221753c4 --- ReactAndroid/src/main/jni/react/jni/OnLoad.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp b/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp index 4865942f7..885ddc1e1 100644 --- a/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp +++ b/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp @@ -520,14 +520,14 @@ namespace runnable { static jclass gNativeRunnableClass; static jmethodID gNativeRunnableCtor; -static jobject createNativeRunnable(JNIEnv* env, decltype(NativeRunnable::callable)&& callable) { - jobject jRunnable = env->NewObject(gNativeRunnableClass, gNativeRunnableCtor); +static LocalReference createNativeRunnable(JNIEnv* env, decltype(NativeRunnable::callable)&& callable) { + LocalReference jRunnable{env->NewObject(gNativeRunnableClass, gNativeRunnableCtor)}; if (env->ExceptionCheck()) { return nullptr; } auto nativeRunnable = createNew(); nativeRunnable->callable = std::move(callable); - setCountableForJava(env, jRunnable, std::move(nativeRunnable)); + setCountableForJava(env, jRunnable.get(), std::move(nativeRunnable)); return jRunnable; } @@ -602,8 +602,8 @@ static void dispatchCallbacksToJava(const RefPtr& weakCallback, } }, std::move(calls)); - jobject jNativeRunnable = runnable::createNativeRunnable(env, std::move(runnableFunction)); - queue::enqueueNativeRunnableOnQueue(env, callbackQueueThread, jNativeRunnable); + auto jNativeRunnable = runnable::createNativeRunnable(env, std::move(runnableFunction)); + queue::enqueueNativeRunnableOnQueue(env, callbackQueueThread, jNativeRunnable.get()); } static void create(JNIEnv* env, jobject obj, jobject executor, jobject callback,