Intentional behavior of signal child_order_changed?

Godot Version

4.3.stable / 4.4.rc1

Question

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.

1 Like

Thanks for your answer.

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.

1 Like