diff options
author | Radiant <69520693+RadiantUwU@users.noreply.github.com> | 2024-08-02 16:26:19 +0300 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-09-16 17:02:35 +0200 |
commit | 7266418bdfa0a0b458b8fd3366efb6a271fdfade (patch) | |
tree | f5d53639b88fb42b5aa2608d5b9f37b4deb7ed17 /scene | |
parent | b7fc0630381a766a5065f49b8b14079f581cdc4e (diff) | |
download | redot-engine-7266418bdfa0a0b458b8fd3366efb6a271fdfade.tar.gz |
Fix node.duplicate, return nullptr if this operation fails.
(cherry picked from commit 70f41e414eefd21ecbe98d429c5fc82b4c30ce8a)
Diffstat (limited to 'scene')
-rw-r--r-- | scene/main/node.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 0396f3ab4a..15dee69fa5 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2783,9 +2783,11 @@ Node *Node::duplicate(int p_flags) const { ERR_THREAD_GUARD_V(nullptr); Node *dupe = _duplicate(p_flags); + ERR_FAIL_NULL_V_MSG(dupe, nullptr, "Failed to duplicate node."); + _duplicate_properties(this, this, dupe, p_flags); - if (dupe && (p_flags & DUPLICATE_SIGNALS)) { + if (p_flags & DUPLICATE_SIGNALS) { _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; Node *dupe = _duplicate(flags, &r_duplimap); + ERR_FAIL_NULL_V_MSG(dupe, nullptr, "Failed to duplicate node."); + _duplicate_properties(this, this, dupe, flags); // This is used by SceneTreeDock's paste functionality. When pasting to foreign scene, resources are duplicated. |