Fix stale-node crash in UI sound auto-wiring
node_added already fires once per node as it enters the tree (including every descendant of a newly-added subtree), so the recursive call_deferred in _on_node_added was redundant and held a raw Node reference across a frame boundary. If that node got freed before the deferred call fired (e.g. a container torn down and rebuilt the same frame), the engine's message queue couldn't marshal the argument and threw "Cannot convert argument 1 from Object to Object". Wiring synchronously removes the window entirely. Also silences the intentional integer division in _duration_text, matching the same annotation already applied to _elapsed_simulated_text.
This commit is contained in:
@@ -88,7 +88,8 @@ func _next_available_player() -> AudioStreamPlayer:
|
|||||||
|
|
||||||
|
|
||||||
func _on_node_added(node: Node) -> void:
|
func _on_node_added(node: Node) -> void:
|
||||||
call_deferred("_wire_node", node)
|
if node is Button:
|
||||||
|
_wire_button(node)
|
||||||
|
|
||||||
|
|
||||||
func _wire_existing_buttons() -> void:
|
func _wire_existing_buttons() -> void:
|
||||||
|
|||||||
@@ -917,6 +917,7 @@ func _elapsed_simulated_text(minutes: int) -> String:
|
|||||||
|
|
||||||
|
|
||||||
func _duration_text(seconds: int) -> String:
|
func _duration_text(seconds: int) -> String:
|
||||||
|
@warning_ignore("integer_division")
|
||||||
return "%02d:%02d" % [seconds / 60, seconds % 60]
|
return "%02d:%02d" % [seconds / 60, seconds % 60]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user