FIX: smooth_nodes may crash due to broken parent-child chain

Change-Id: I770df691b41c6f18a0cb97e49e9e2251afe02e1a
(cherry picked from commit 2b5cdf0337fff277f7b949da568d6cdaa28a0d35)
This commit is contained in:
lane.wei 2023-02-15 12:03:55 +08:00 committed by Lane.Wei
parent 8d7fb45164
commit 5df5cb9ff4

View file

@ -3000,7 +3000,11 @@ void TreeSupport::drop_nodes(std::vector<std::vector<Node*>>& contact_nodes)
std::vector<Node*>::iterator to_erase = std::find(contact_nodes[i_layer].begin(), contact_nodes[i_layer].end(), i_node); std::vector<Node*>::iterator to_erase = std::find(contact_nodes[i_layer].begin(), contact_nodes[i_layer].end(), i_node);
if (to_erase != contact_nodes[i_layer].end()) if (to_erase != contact_nodes[i_layer].end())
{ {
to_free_node_set.insert(*to_erase); // update the parent-child chain
if(i_node->parent)
i_node->parent->child = i_node->child;
if(i_node->child)
i_node->child->parent = i_node->parent;
contact_nodes[i_layer].erase(to_erase); contact_nodes[i_layer].erase(to_erase);
to_free_node_set.insert(i_node); to_free_node_set.insert(i_node);