You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2018/11/15 07:09:11 UTC

[GitHub] YorkShen closed pull request #1761: *[core] fix env or jni object nullptr

YorkShen closed pull request #1761: *[core] fix env or jni object nullptr
URL: https://github.com/apache/incubator-weex/pull/1761
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/weex_core/Source/base/message_loop/message_pump_android.cc b/weex_core/Source/base/message_loop/message_pump_android.cc
index 765fa19343..a4ad40892e 100644
--- a/weex_core/Source/base/message_loop/message_pump_android.cc
+++ b/weex_core/Source/base/message_loop/message_pump_android.cc
@@ -49,16 +49,25 @@ void MessagePumpAndroid::Run(Delegate* delegate) {
 
 void MessagePumpAndroid::Stop() {
   JNIEnv* env = ::base::android::AttachCurrentThread();
+  if(!env || !jni_object()) {
+    return;
+  }
   Java_SystemMessageHandler_stop(env, jni_object());
 }
 
 void MessagePumpAndroid::ScheduleWork() {
   JNIEnv* env = ::base::android::AttachCurrentThread();
+  if(!env || !jni_object()) {
+    return;
+  }
   Java_SystemMessageHandler_scheduleWork(env, jni_object());
 }
 
 void MessagePumpAndroid::ScheduleDelayedWork(TimeUnit delayed_time) {
   JNIEnv* env = ::base::android::AttachCurrentThread();
+  if(!env || !jni_object()) {
+    return;
+  }
   Java_SystemMessageHandler_scheduleDelayedWork(env, jni_object(),
                                                 delayed_time.ToMilliseconds());
 }
diff --git a/weex_core/Source/core/layout/measure_func_adapter_impl_android.h b/weex_core/Source/core/layout/measure_func_adapter_impl_android.h
index 6703b56dab..444ec4c2ff 100644
--- a/weex_core/Source/core/layout/measure_func_adapter_impl_android.h
+++ b/weex_core/Source/core/layout/measure_func_adapter_impl_android.h
@@ -46,6 +46,7 @@ namespace WeexCore {
       }
 
       JNIEnv* env = base::android::AttachCurrentThread();
+      if (!env) return size;
 
       cumsmeasure_Imple_Android(env, measureFunc,
                                 width, height,
@@ -65,6 +66,7 @@ namespace WeexCore {
       }
 
         JNIEnv *env = base::android::AttachCurrentThread();
+      if (!env) return;
       LayoutBeforeImplAndroid(env, measureFunc);
       env->DeleteLocalRef(measureFunc);
     }
@@ -75,6 +77,7 @@ namespace WeexCore {
         return;
       }
         JNIEnv *env = base::android::AttachCurrentThread();
+      if (!env) return;
       LayoutAfterImplAndroid(env, measureFunc, width, height);
       env->DeleteLocalRef(measureFunc);
     }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services