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.
This commit is contained in:
Rémi Verschelde 2019-05-28 12:40:39 +02:00
parent 8384582828
commit 0823ae7ae4
1 changed files with 3 additions and 1 deletions

View File

@ -2077,7 +2077,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)