Merge pull request #116286 from kleonc/node_replace_by_dont_remove_internal_nodes

Don't remove internal nodes in `Node::replace_by`
This commit is contained in:
Thaddeus Crews
2026-04-10 10:32:12 -05:00
+7 -9
View File
@@ -3241,16 +3241,14 @@ void Node::replace_by(RequiredParam<Node> rp_node, bool p_keep_groups) {
emit_signal(SNAME("replacing_by"), p_node);
while (get_child_count()) {
Node *child = get_child(0);
// Move non-internal children to `p_node`.
while (get_child_count(false)) {
Node *child = get_child(0, false);
remove_child(child);
if (!child->is_internal()) {
// Add the custom children to the p_node.
Node *child_owner = child->get_owner() == this ? p_node : child->get_owner();
child->set_owner(nullptr);
p_node->add_child(child);
child->set_owner(child_owner);
}
Node *child_owner = child->get_owner() == this ? p_node : child->get_owner();
child->set_owner(nullptr);
p_node->add_child(child);
child->set_owner(child_owner);
}
p_node->set_owner(owner);