When nodes get unloaded for example because a new scene is loaded or get_tree().quit() is called, the signal child_order_changed on a parent is called for every child.
This behavior got my attention because it caused a bug (previously freed null instance). A function I connected with child_order_changed tryed to set a variable of an already freed object.
Could this be intentional?
If so, what could be the use case?
Yeah, that looks intentional. I assume because it’s semantically correct. Any node removed or added will change the following nodes’ order. I see how on quit can cause difficulties. I don’t know of any use cases.
Yes, it feels plausible but proun to errors too.
One can use is_instance_valid() to protect from resulting errors or disconnect from the signal beforehand but it still feels a bit dirty.