weex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ky...@apache.org
Subject [1/3] incubator-weex git commit: [WEEX-376][Android] Fix updateAttrs crash
Date Tue, 22 May 2018 10:20:47 GMT
Repository: incubator-weex
Updated Branches:
  refs/heads/master 7102479d9 -> 2d93c1c55


[WEEX-376][Android] Fix updateAttrs crash


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/4dd5b4fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/4dd5b4fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/4dd5b4fc

Branch: refs/heads/master
Commit: 4dd5b4fc2e387742fd0a73af2e405130f6efb177
Parents: 7102479
Author: miomin <miomin_93@foxmail.com>
Authored: Tue May 22 15:13:23 2018 +0800
Committer: miomin <miomin_93@foxmail.com>
Committed: Tue May 22 15:13:23 2018 +0800

----------------------------------------------------------------------
 .../com/taobao/weex/common/WXErrorCode.java     |  1 +
 .../taobao/weex/ui/component/WXComponent.java   | 43 ++++++++++++--------
 weex_core/Source/core/parser/dom_parser.cpp     |  1 -
 3 files changed, 27 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4dd5b4fc/android/sdk/src/main/java/com/taobao/weex/common/WXErrorCode.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/common/WXErrorCode.java b/android/sdk/src/main/java/com/taobao/weex/common/WXErrorCode.java
index 467da61..6d51a92 100644
--- a/android/sdk/src/main/java/com/taobao/weex/common/WXErrorCode.java
+++ b/android/sdk/src/main/java/com/taobao/weex/common/WXErrorCode.java
@@ -231,6 +231,7 @@ public enum WXErrorCode {
   WX_RENDER_ERR_JS_CREATE_INSTANCE("-9600", "WX_RENDER_ERR_JS_CREATE_INSTANCE",ErrorType.RENDER_ERROR,ErrorGroup.JS),
   WX_RENDER_ERR_JS_RUNTIME("-9601", "WX_RENDER_ERR for js error",ErrorType.RENDER_ERROR,
ErrorGroup.JS),
   WX_RENDER_ERR_LAYER_OVERFLOW("-9602", "WX_RENDER_ERR_LAYER_OVERFLOW", ErrorType.NATIVE_ERROR,
ErrorGroup.NATIVE),
+  WX_RENDER_ERR_NULL_KEY("-9603", "WX_RENDER_ERR_NULL_KEY", ErrorType.NATIVE_ERROR, ErrorGroup.NATIVE),
   WX_RENDER_ERR_CONTAINER_TYPE("-9611", "WX_RENDER_ERR_CONTAINER_TYPE", ErrorType.JS_ERROR,ErrorGroup.JS),
 
 

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4dd5b4fc/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
index b7e2476..74a81fd 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
@@ -18,6 +18,7 @@
  */
 package com.taobao.weex.ui.component;
 
+import com.taobao.weex.common.WXErrorCode;
 import com.taobao.weex.dom.CSSShorthand.CORNER;
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
@@ -115,6 +116,7 @@ import com.taobao.weex.ui.view.gesture.WXGestureObservable;
 import com.taobao.weex.ui.view.gesture.WXGestureType;
 import com.taobao.weex.utils.BoxShadowUtil;
 import com.taobao.weex.utils.WXDataStructureUtil;
+import com.taobao.weex.utils.WXExceptionUtils;
 import com.taobao.weex.utils.WXLogUtils;
 import com.taobao.weex.utils.WXReflectionUtils;
 import com.taobao.weex.utils.WXResourceUtils;
@@ -661,25 +663,32 @@ public abstract class WXComponent<T extends View> extends WXBasicComponent
imple
       String key = entry.getKey();
       Object param = entry.getValue();
       String value = WXUtils.getString(param, null);
-      if (TextUtils.isEmpty(value)) {
-        param = convertEmptyProperty(key, value);
-      }
-      if (!setProperty(key, param)) {
-        if (mHolder == null) {
-          return;
+
+      if (key == null) {
+        WXExceptionUtils.commitCriticalExceptionRT(getInstanceId(),
+                WXErrorCode.WX_RENDER_ERR_NULL_KEY, "updateProperties",
+                WXErrorCode.WX_RENDER_ERR_NULL_KEY.getErrorMsg(), null);
+      } else {
+        if (TextUtils.isEmpty(value)) {
+          param = convertEmptyProperty(key, value);
         }
-        Invoker invoker = mHolder.getPropertyInvoker(key);
-        if (invoker != null) {
-          try {
-            Type[] paramClazzs = invoker.getParameterTypes();
-            if (paramClazzs.length != 1) {
-              WXLogUtils.e("[WXComponent] setX method only one parameter:" + invoker);
-              return;
+        if (!setProperty(key, param)) {
+          if (mHolder == null) {
+            return;
+          }
+          Invoker invoker = mHolder.getPropertyInvoker(key);
+          if (invoker != null) {
+            try {
+              Type[] paramClazzs = invoker.getParameterTypes();
+              if (paramClazzs.length != 1) {
+                WXLogUtils.e("[WXComponent] setX method only one parameter:" + invoker);
+                return;
+              }
+              param = WXReflectionUtils.parseArgument(paramClazzs[0], param);
+              invoker.invoke(this, param);
+            } catch (Exception e) {
+              WXLogUtils.e("[WXComponent] updateProperties :" + "class:" + getClass() + "method:"
+ invoker.toString() + " function " + WXLogUtils.getStackTrace(e));
             }
-            param = WXReflectionUtils.parseArgument(paramClazzs[0], param);
-            invoker.invoke(this, param);
-          } catch (Exception e) {
-            WXLogUtils.e("[WXComponent] updateProperties :" + "class:" + getClass() + "method:"
+ invoker.toString() + " function " + WXLogUtils.getStackTrace(e));
           }
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4dd5b4fc/weex_core/Source/core/parser/dom_parser.cpp
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/parser/dom_parser.cpp b/weex_core/Source/core/parser/dom_parser.cpp
index 13d9132..216ad72 100644
--- a/weex_core/Source/core/parser/dom_parser.cpp
+++ b/weex_core/Source/core/parser/dom_parser.cpp
@@ -522,7 +522,6 @@ namespace WeexCore {
         std::string value = r.GetObjectStr();
         std::pair<std::string, std::string> myPair(key, value);
         pairs->insert(pairs->end(), myPair);
-        r.SkipValue();
       } else {
         r.SkipValue();
       }


Mime
View raw message