Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1991 from jianhan-he/master
Browse files Browse the repository at this point in the history
merge release/20181220 to master
  • Loading branch information
wqyfavor authored Jan 3, 2019
2 parents 9434662 + 73c9a1b commit 524c455
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
3 changes: 1 addition & 2 deletions ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion weex_core/Source/core/data_render/vnode/vcomponent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions weex_core/Source/core/data_render/vnode/vnode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion weex_core/Source/core/data_render/vnode/vnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
31 changes: 17 additions & 14 deletions weex_core/Source/core/data_render/vnode/vnode_render_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 524c455

Please sign in to comment.