瀏覽代碼

Merge pull request #17321 from LinkDoyle/issue_16350

Fix switching WindowDialog types leaves garbage buttons
Rémi Verschelde 7 年之前
父節點
當前提交
01bb39ac3f
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      scene/main/node.cpp

+ 4 - 1
scene/main/node.cpp

@@ -2502,7 +2502,10 @@ void Node::replace_by(Node *p_node, bool p_keep_data) {
 
 
 		Node *child = get_child(0);
 		Node *child = get_child(0);
 		remove_child(child);
 		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);
 	p_node->set_owner(owner);