Skip to content

Commit

Permalink
Merge pull request godotengine#63130 from snailrhymer/copy-duplicatio…
Browse files Browse the repository at this point in the history
…n-fix

Stop pasted child nodes being assigned an owner when previously unowned
  • Loading branch information
YuriSizov authored Mar 15, 2023
2 parents eada333 + 526d299 commit 0c30a43
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion editor/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,20 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {

ERR_CONTINUE(!dup);

// Preserve ownership relations ready for pasting.
List<Node *> owned;
node->get_owned_by(node->get_owner(), &owned);

for (Node *F : owned) {
if (!duplimap.has(F) || F == node) {
continue;
}
Node *d = duplimap[F];
// Only use this as a marker that ownership needs to be assigned when pasting.
// The actual owner doesn't matter.
d->set_owner(dup);
}

node_clipboard.push_back(dup);
}

Expand Down Expand Up @@ -3239,7 +3253,8 @@ List<Node *> SceneTreeDock::paste_nodes() {

for (KeyValue<const Node *, Node *> &E2 : duplimap) {
Node *d = E2.value;
if (d != dup) {
// When copying, all nodes that should have an owner assigned here were given node as an owner.
if (d != dup && E2.key->get_owner() == node) {
ur->add_do_method(d, "set_owner", owner);
}
}
Expand Down

0 comments on commit 0c30a43

Please sign in to comment.