-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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 crash on removing added sibling in _ready
#78834
base: master
Are you sure you want to change the base?
Conversation
Could you provide a reproduction project? |
Better yet a formal bug report to track this in case this doesn't solve it |
Updated description with reproduction example |
Awaiting parent Also why is Edit: realized that won't necessarily catch this as it's not blocked at this point |
I though the purpose of the |
It's not safe, it's explicitly saying that you can't add children to parent if you try it:
You should do this in a separate function, or do the deferred call to keep this safe Does this happen if you call |
While we should prevent the crash, this example looks confusing. What's the real life need for this kind of logic?
I don't understand the intent here, and as mentioned As for the crash, we likely need to catch its condition with an |
I orignally came across this bug when making a building game. The logic was as follows:
My rationale for not throwing an error here was that replacing That being said, What do you think @YuriSizov @AThousandShips ? |
I think for now we can go with #78847 and then re-evaluate if there are still problems that cause crashes for your example. Then we can either update this PR to address them, or close it as superseded if #78847 ends up fixing all of it. |
As far as I understand #78834 (comment), the bug will not be completely fixed by #78847, which solves a related problem. As mentioned above, it should be investigated, if a |
I think the example I used in the description has caused some confusion, especially in my use of running the example in the extends Button
class MyNode extends Node:
func _ready() -> void:
get_parent().remove_child(self)
func _pressed() -> void:
add_sibling(MyNode.new())
The only way to address this with
|
Can't reproduce the crash in 4.3. |
_ready
I can reproduce a crash with the script in the OP on 4.3-rc2 and latest
|
Looks like the crash does not happen if the node is a child of scene root, only when it's nested. |
Why are you adding the part with |
If a Node that was added to the tree via
add_sibling()
was removed/reparented in its_ready()
function, it would cause a crash.Example: