1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-16 14:00:40 +00:00

Merge pull request #84824 from Rindbee/fix-double-internal-node

Fix duplicating sub-scene may get two copies of internal node
This commit is contained in:
Rémi Verschelde
2024-02-09 12:14:29 +01:00

View File

@@ -2549,6 +2549,11 @@ Node *Node::_duplicate(int p_flags, HashMap<const Node *, Node *> *r_duplimap) c
for (List<const Node *>::Element *N = node_tree.front(); N; N = N->next()) { for (List<const Node *>::Element *N = node_tree.front(); N; N = N->next()) {
for (int i = 0; i < N->get()->get_child_count(); ++i) { for (int i = 0; i < N->get()->get_child_count(); ++i) {
Node *descendant = N->get()->get_child(i); Node *descendant = N->get()->get_child(i);
if (!descendant->get_owner()) {
continue; // Internal nodes or nodes added by scripts.
}
// Skip nodes not really belonging to the instantiated hierarchy; they'll be processed normally later // Skip nodes not really belonging to the instantiated hierarchy; they'll be processed normally later
// but remember non-instantiated nodes that are hidden below instantiated ones // but remember non-instantiated nodes that are hidden below instantiated ones
if (!instance_roots.has(descendant->get_owner())) { if (!instance_roots.has(descendant->get_owner())) {