From 7ef01161ed17eda65013d4acacb36aba5c9cf1ba Mon Sep 17 00:00:00 2001 From: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Date: Sat, 9 Oct 2021 08:58:27 +0100 Subject: [PATCH] Fixed circuit variables not working because of a null listener in their listener list (#61961) Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com> --- code/modules/wiremod/core/variable.dm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/modules/wiremod/core/variable.dm b/code/modules/wiremod/core/variable.dm index 2153688d7bf..2bebc4e7e89 100644 --- a/code/modules/wiremod/core/variable.dm +++ b/code/modules/wiremod/core/variable.dm @@ -38,10 +38,16 @@ for(var/obj/item/circuit_component/component as anything in listeners) component.trigger_component() +/datum/circuit_variable/proc/on_listener_qdel(datum/listener) + SIGNAL_HANDLER + listeners -= listener + /// Adds a listener to receive inputs when the variable has a value that is set. /datum/circuit_variable/proc/add_listener(obj/item/circuit_component/to_add) listeners += to_add + RegisterSignal(to_add, COMSIG_PARENT_QDELETING, .proc/on_listener_qdel) /// Removes a listener to receive inputs when the variable has a value that is set. Listener will usually clean themselves up /datum/circuit_variable/proc/remove_listener(obj/item/circuit_component/to_remove) + UnregisterSignal(to_remove, COMSIG_PARENT_QDELETING) listeners -= to_remove