From 7b1ad978138c49c7e68585a41d3e4fe864ac1e80 Mon Sep 17 00:00:00 2001 From: sospartan Date: Wed, 17 Aug 2016 16:48:25 +0800 Subject: [PATCH] * [android] fix invaild add dom operation --- .../src/main/java/com/taobao/weex/dom/WXDomStatement.java | 4 ++++ .../src/main/java/com/taobao/weex/ui/WXRenderManager.java | 2 +- .../src/main/java/com/taobao/weex/ui/WXRenderStatement.java | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomStatement.java b/android/sdk/src/main/java/com/taobao/weex/dom/WXDomStatement.java index 22d2d84dca..57994c89d5 100755 --- a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomStatement.java +++ b/android/sdk/src/main/java/com/taobao/weex/dom/WXDomStatement.java @@ -646,6 +646,10 @@ void addDom(JSONObject dom, final String parentRef, final int index) { //Create component in dom thread final WXComponent component = mWXRenderManager.createComponentOnDomThread(mInstanceId, domObject, parentRef, index); + if(component == null){ + //stop redner, some fatal happened. + return; + } AddDomInfo addDomInfo = new AddDomInfo(); addDomInfo.component = component; mAddDom.put(domObject.getRef(), addDomInfo); diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderManager.java b/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderManager.java index c669329088..04494c46e0 100755 --- a/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderManager.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderManager.java @@ -343,7 +343,7 @@ public void addComponent(String instanceId, WXDomObject dom, String parentRef, i statement.addComponent(dom, parentRef, index); } - public WXComponent createComponentOnDomThread(String instanceId, WXDomObject dom, String parentRef, int index) { + public @Nullable WXComponent createComponentOnDomThread(String instanceId, WXDomObject dom, String parentRef, int index) { WXRenderStatement statement = mRegistries.get(instanceId); if (statement == null) { return null; diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderStatement.java b/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderStatement.java index 5d134968b6..f2af171e75 100755 --- a/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderStatement.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderStatement.java @@ -364,7 +364,11 @@ void addComponent(WXDomObject dom, String parentRef, int index) { parent.addChild(component, index); } - WXComponent createComponentOnDomThread(WXDomObject dom, String parentRef, int index) { + @Nullable WXComponent createComponentOnDomThread(WXDomObject dom, String parentRef, int index) { + WXComponent comp = mRegistry.get(parentRef); + if(comp == null || !(comp instanceof WXVContainer)){ + return null; + } return generateComponentTree(dom, (WXVContainer) mRegistry.get(parentRef)); }