Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ownership bugs in node copy and pasting. #83596

Merged
merged 1 commit into from
Nov 6, 2023

Conversation

SaracenOne
Copy link
Member

@SaracenOne SaracenOne commented Oct 19, 2023

The implementation of this is a little bit clunky, but it seems to work. The reason to maintain an extra list of nodes is because it currently it seems there's no way to distinguish between either nodes owned by the selected nodes and nodes we actually want to reassign to the new edited scene. I tried initially setting them to just nullptr owners instead, but this led to it including actual ownerless nodes being included in the copy/paste. Maintaining an extra list seems to solve this ambiguity.

Closes #83594

While an independent enhancement, would also recommend merging this PR too which provides complimentary functionality and fixes to re-enable duplication of foreign nodes #83597

editor/scene_tree_dock.h Outdated Show resolved Hide resolved
Comment on lines 507 to 510
if (!duplimap.has(F) || F == node) {
continue;
}
Node *d = duplimap[F];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!duplimap.has(F) || F == node) {
continue;
}
Node *d = duplimap[F];
if (F == node) {
continue;
}
HashMap<const Node *, Node *>::Iterator G = duplimap.find(F);
if (!G) {
continue;
}
Node *d = G->value;

Unrelated to this PR, but this code can be improved.

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably makes sense.
It works and the code looks ok.

@SaracenOne
Copy link
Member Author

Converted to HashSet now.

@YuriSizov YuriSizov merged commit 8b11ae9 into godotengine:master Nov 6, 2023
15 checks passed
@YuriSizov
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Copy/Pasting foreign node behaviour is incorrect
3 participants