Node::duplicate: Don't set name if original node is nameless

In practice this only happens when duplicating a node which is not in
the scene tree yet, as nameless nodes get assigned a generated name
when added to the scene tree.

Fixes #27319.

(cherry picked from commit 0823ae7ae4)
This commit is contained in:
Rémi Verschelde 2019-05-28 12:40:39 +02:00
parent 88cccfb796
commit 9591e2950a
1 changed files with 3 additions and 1 deletions

View File

@ -2063,7 +2063,9 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
} }
} }
node->set_name(get_name()); if (get_name() != String()) {
node->set_name(get_name());
}
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
if ((p_flags & DUPLICATE_FROM_EDITOR) && r_duplimap) if ((p_flags & DUPLICATE_FROM_EDITOR) && r_duplimap)