From e26c94fedb3d5b06d10e572d2f1797775bd285a5 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 9 Oct 2025 00:14:43 +0200 Subject: Fix double connected signals (close #441) --- client/system/settings.gd | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/system/settings.gd b/client/system/settings.gd index 12b14857..14c6d0db 100644 --- a/client/system/settings.gd +++ b/client/system/settings.gd @@ -134,7 +134,8 @@ static func hook_changed(key: String, slot, callable: Callable): var slot_id = 0 if slot is Node: slot_id = slot.get_instance_id() - slot.tree_exiting.connect(_unhook_changed.bind(key, slot_id), CONNECT_ONE_SHOT) + if not slot.tree_exiting.is_connected(_unhook_changed): + slot.tree_exiting.connect(_unhook_changed.bind(slot_id), CONNECT_ONE_SHOT) elif slot is String: slot_id = slot.hash() else: @@ -143,8 +144,9 @@ static func hook_changed(key: String, slot, callable: Callable): if not change_hooks.has(key): change_hooks[key] = {} change_hooks[key][slot_id] = callable -static func _unhook_changed(key: String, slot_id: int): - change_hooks[key].erase(slot_id) +static func _unhook_changed(slot_id: int): + for key in change_hooks: + change_hooks[key].erase(slot_id) # slot: String | Node static func hook_changed_init(key: String, slot, callable: Callable): -- cgit v1.3