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 2019/01/03 09:24:02 UTC

[GitHub] wqyfavor closed pull request #1991: merge release/20181220 to master

wqyfavor closed pull request #1991: merge release/20181220 to master
URL: https://github.com/apache/incubator-weex/pull/1991
 
 
   

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/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
index 6f55eb43f5..1470df71db 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
@@ -700,9 +700,8 @@ - (void)destroyInstance:(NSString *)instance
         WXPerformBlockOnComponentThread(^{
             [WXCoreBridge destroyDataRenderInstance:instance];
         });
-    } else {
-        [self callJSMethod:@"destroyInstance" args:@[instance]];
     }
+    [self callJSMethod:@"destroyInstance" args:@[instance]];
 }
 
 - (void)forceGarbageCollection
diff --git a/weex_core/Source/core/data_render/vnode/vcomponent.cc b/weex_core/Source/core/data_render/vnode/vcomponent.cc
index c4243dc059..2532cd30cd 100644
--- a/weex_core/Source/core/data_render/vnode/vcomponent.cc
+++ b/weex_core/Source/core/data_render/vnode/vcomponent.cc
@@ -45,7 +45,11 @@ VComponent::VComponent(ExecState *exec_state, int template_id,
       root_vnode_(nullptr),
       exec_state_(exec_state) {}
 
-VComponent::~VComponent() {}
+VComponent::~VComponent() {
+  if (listener_ && !has_moved_) {
+    listener_->OnDestroyed(this);
+  }
+}
 
 static bool Equals(Value a, Value b) {
   if (a.type != b.type) {
diff --git a/weex_core/Source/core/data_render/vnode/vnode.cc b/weex_core/Source/core/data_render/vnode/vnode.cc
index 219ca1cb75..4524cc17d5 100644
--- a/weex_core/Source/core/data_render/vnode/vnode.cc
+++ b/weex_core/Source/core/data_render/vnode/vnode.cc
@@ -132,6 +132,7 @@ void VNode::AddChild(VNode *child) {
 void VNode::InsertChild(VNode *child, int index) {
   if (!child) return;
   child->parent_ = this;
+  child->component_ = component_;
   if (index < child_list_.size()) {
     child_list_.insert(child_list_.begin() + index, child);
   } else {
diff --git a/weex_core/Source/core/data_render/vnode/vnode.h b/weex_core/Source/core/data_render/vnode/vnode.h
index 8cda5e5015..573915c645 100644
--- a/weex_core/Source/core/data_render/vnode/vnode.h
+++ b/weex_core/Source/core/data_render/vnode/vnode.h
@@ -112,8 +112,11 @@ class VNode {
 
   inline bool HasChildren() { return !child_list_.empty(); }
 
-  inline void set_component(VComponent* c) {
+  void set_component(VComponent* c) {
     component_ = c;
+    for (auto child : child_list_) {
+      child->set_component(c);
+    }
   }
 
   inline VComponent* component() {
diff --git a/weex_core/Source/core/data_render/vnode/vnode_render_manager.cc b/weex_core/Source/core/data_render/vnode/vnode_render_manager.cc
index 5875fee382..e85aed8b0b 100644
--- a/weex_core/Source/core/data_render/vnode/vnode_render_manager.cc
+++ b/weex_core/Source/core/data_render/vnode/vnode_render_manager.cc
@@ -451,7 +451,7 @@ void VNodeRenderManager::FireEvent(const std::string &page_id, const std::string
         {
             // First way to fire event from VNode::OnEvent
             auto vnode = iter->second->context()->GetVNode(ref);
-            if (vnode) {
+            if (vnode && vnode->event_params_map()) {
                 auto hit_test = vnode->event_params_map()->find(event);
                 if (hit_test != vnode->event_params_map()->end()) {
                     // If vnode has eat event, return.
@@ -463,7 +463,6 @@ void VNodeRenderManager::FireEvent(const std::string &page_id, const std::string
 
         // Second way to fire event from call vm func
         auto vnode = node->second->FindNode(ref);
-        if (vnode == nullptr)
         if (!vnode) {
             break;
         }
@@ -868,24 +867,26 @@ void CompareAndApplyEvents1(const std::string& page_id, VNode* old_node,
                             VNode* new_node) {
   std::map<std::string, void*> old_events = *old_node->events();
   std::map<std::string, void*> new_events = *new_node->events();
+  std::map<std::string, void*> remove_events;
+  std::map<std::string, void*> add_events;
 
   for (auto it = old_events.cbegin(); it != old_events.cend(); it++) {
     auto pos = new_events.find(it->first);
-    if (pos != new_events.end()) {
-      new_events.erase(pos);
+    if (pos == new_events.end()) {
+      remove_events.insert(*it);
     }
   }
   for (auto it = new_events.cbegin(); it != new_events.cend(); it++) {
     auto pos = old_events.find(it->first);
-    if (pos != old_events.end()) {
-      old_events.erase(pos);
+    if (pos == old_events.end()) {
+      add_events.insert(*it);
     }
   }
-  for (auto it = old_events.cbegin(); it != old_events.cend(); it++) {
+  for (auto it = remove_events.cbegin(); it != remove_events.cend(); it++) {
     RenderManager::GetInstance()->RemoveEvent(
         page_id, new_node->render_object_ref(), it->first);
   }
-  for (auto it = new_events.cbegin(); it != new_events.cend(); it++) {
+  for (auto it = add_events.cbegin(); it != add_events.cend(); it++) {
     RenderManager::GetInstance()->AddEvent(
         page_id, new_node->render_object_ref(), it->first);
   }
@@ -896,25 +897,27 @@ void CompareAndApplyEvents2(const std::string& page_id, VNode* old_node,
   VNode::EventParamsMap old_events = *old_node->event_params_map();
   VNode::EventParamsMap new_events = *new_node->event_params_map();
 
+  VNode::EventParamsMap remove_events;
+  VNode::EventParamsMap add_events;
   for (auto it = old_events.cbegin(); it != old_events.cend(); it++) {
     auto pos = new_events.find(it->first);
 
-    if (pos != new_events.end()) {
-      new_events.erase(pos);
+    if (pos == new_events.end()) {
+        remove_events.insert(*it);
     }
   }
   for (auto it = new_events.cbegin(); it != new_events.cend(); it++) {
     auto pos = old_events.find(it->first);
 
-    if (pos != old_events.end()) {
-      old_events.erase(pos);
+    if (pos == old_events.end()) {
+        add_events.insert(*it);
     }
   }
-  for (auto it = old_events.cbegin(); it != old_events.cend(); it++) {
+  for (auto it = remove_events.cbegin(); it != remove_events.cend(); it++) {
     RenderManager::GetInstance()->RemoveEvent(
         page_id, new_node->render_object_ref(), it->first);
   }
-  for (auto it = new_events.cbegin(); it != new_events.cend(); it++) {
+  for (auto it = add_events.cbegin(); it != add_events.cend(); it++) {
     RenderManager::GetInstance()->AddEvent(
         page_id, new_node->render_object_ref(), it->first);
   }


 

----------------------------------------------------------------
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