HungryProton / scatter

Godot engine addon to randomly fill an area with props or other scenes
MIT License
2.18k stars 97 forks source link

Check if tree exists to avoid null exception when processing frame #171

Closed Runkli closed 1 year ago

Runkli commented 1 year ago

Problem freeing a child node (with a scatter node in it) after removing it from a tree causes null exception.

Description Assume I have a tree, with a child node in it. This child node has a scatter node in it. If I try to remove the child node from the tree, and then try to free the node, there will be a null exception in _on_transforms_ready at await get_tree().process_frame, because the node is no longer in a tree.

Solution Check if the tree exists before processing frame.

I'm not sure if this is the correct way to do it, but it lets me do what I wanted to do (free object after removing it from a tree)

HungryProton commented 1 year ago

Thanks for the PR!