From 611c05046948693a7b23ca697f73b9217f1a7c6f Mon Sep 17 00:00:00 2001 From: Link Date: Wed, 7 Mar 2018 08:21:46 +0800 Subject: Fix switching WindowDialog types leaves garbage buttons We can distinguish between node-specific children and custom children by `child->is_owned_by_parent()`. Fixes: #16350 --- scene/main/node.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scene') diff --git a/scene/main/node.cpp b/scene/main/node.cpp index cf22383e36..28b4540573 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2502,7 +2502,10 @@ void Node::replace_by(Node *p_node, bool p_keep_data) { Node *child = get_child(0); remove_child(child); - p_node->add_child(child); + if (!child->is_owned_by_parent()) { + // add the custom children to the p_node + p_node->add_child(child); + } } p_node->set_owner(owner); -- cgit v1.2.3