Fix node.duplicate, return nullptr if this operation fails.
This commit is contained in:
parent
607b230ffe
commit
70f41e414e
1 changed files with 5 additions and 1 deletions
|
@ -2783,9 +2783,11 @@ Node *Node::duplicate(int p_flags) const {
|
||||||
ERR_THREAD_GUARD_V(nullptr);
|
ERR_THREAD_GUARD_V(nullptr);
|
||||||
Node *dupe = _duplicate(p_flags);
|
Node *dupe = _duplicate(p_flags);
|
||||||
|
|
||||||
|
ERR_FAIL_NULL_V_MSG(dupe, nullptr, "Failed to duplicate node.");
|
||||||
|
|
||||||
_duplicate_properties(this, this, dupe, p_flags);
|
_duplicate_properties(this, this, dupe, p_flags);
|
||||||
|
|
||||||
if (dupe && (p_flags & DUPLICATE_SIGNALS)) {
|
if (p_flags & DUPLICATE_SIGNALS) {
|
||||||
_duplicate_signals(this, dupe);
|
_duplicate_signals(this, dupe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2801,6 +2803,8 @@ Node *Node::duplicate_from_editor(HashMap<const Node *, Node *> &r_duplimap, con
|
||||||
int flags = DUPLICATE_SIGNALS | DUPLICATE_GROUPS | DUPLICATE_SCRIPTS | DUPLICATE_USE_INSTANTIATION | DUPLICATE_FROM_EDITOR;
|
int flags = DUPLICATE_SIGNALS | DUPLICATE_GROUPS | DUPLICATE_SCRIPTS | DUPLICATE_USE_INSTANTIATION | DUPLICATE_FROM_EDITOR;
|
||||||
Node *dupe = _duplicate(flags, &r_duplimap);
|
Node *dupe = _duplicate(flags, &r_duplimap);
|
||||||
|
|
||||||
|
ERR_FAIL_NULL_V_MSG(dupe, nullptr, "Failed to duplicate node.");
|
||||||
|
|
||||||
_duplicate_properties(this, this, dupe, flags);
|
_duplicate_properties(this, this, dupe, flags);
|
||||||
|
|
||||||
// This is used by SceneTreeDock's paste functionality. When pasting to foreign scene, resources are duplicated.
|
// This is used by SceneTreeDock's paste functionality. When pasting to foreign scene, resources are duplicated.
|
||||||
|
|
Loading…
Reference in a new issue