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

Clarify that replace_by keeps child nodes in tree #55777

Merged
merged 1 commit into from
Dec 15, 2021

Conversation

cdemirer
Copy link
Contributor

@cdemirer cdemirer commented Dec 10, 2021

Closes #28746
Related: #55710

The name of this function seems to cause confusion. It can sound as if it would be replacing a whole subtree, or as if it replaces a single node with another single node. In truth it's neither: A single node is removed from the tree, while a subtree is added to the tree. The children of the replaced node are reparented to the new node, resulting in a merged list of child nodes.

Mentioning this behavior in the documentation could help prevent misuse / unexpected behavior.

@cdemirer cdemirer requested a review from a team as a code owner December 10, 2021 06:00
@YuriSizov YuriSizov added documentation topic:core cherrypick:3.x Considered for cherry-picking into a future 3.x release labels Dec 10, 2021
@YuriSizov YuriSizov added this to the 4.0 milestone Dec 10, 2021
@mhilbrunner mhilbrunner merged commit 9d81bfe into godotengine:master Dec 15, 2021
@mhilbrunner
Copy link
Member

Thank you!

@cdemirer cdemirer deleted the doc-replace_by branch December 15, 2021 07:54
@akien-mga
Copy link
Member

Cherry-picked for 3.5.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Dec 21, 2021
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.

Node.replace_by() has strange behavior with instanced scenes
4 participants