From 7fb33032f66df1b2b88b19441374e089a45da676 Mon Sep 17 00:00:00 2001 From: Andy Street Date: Thu, 3 Mar 2016 07:51:51 -0800 Subject: [PATCH] Copy weak reference to callback object when dispatching calls to Java Summary: The bridge could be destructed, meaning we can't try to resolve member variables of PlatformBridgeCallback. Reviewed By: lexs Differential Revision: D3005994 fb-gh-sync-id: f83de432148ce62fd1060c6b84ec39ad2fa10a55 shipit-source-id: f83de432148ce62fd1060c6b84ec39ad2fa10a55 --- ReactAndroid/src/main/jni/react/jni/OnLoad.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp b/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp index eeef4d6fe..4748d825c 100644 --- a/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp +++ b/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp @@ -629,13 +629,13 @@ public: return; } - auto runnableWrapper = std::bind([this] (std::function& runnable) { + auto runnableWrapper = std::bind([weakCallback=weakCallback_] (std::function& runnable) { auto env = Environment::current(); if (env->ExceptionCheck()) { FBLOGW("Dropped calls because of pending exception"); return; } - ResolvedWeakReference callback(weakCallback_); + ResolvedWeakReference callback(weakCallback); if (callback) { runnable(callback); }