From fb4cf2e80a197882fa6ed23da0a298ad89ad9cd8 Mon Sep 17 00:00:00 2001 From: Will <7099514+Willburd@users.noreply.github.com> Date: Tue, 21 Apr 2026 04:57:02 -0400 Subject: [PATCH] Weakref cleanup (#19382) * oh god help * fixes * oops * container runtime --------- Co-authored-by: Cameron Lennox --- code/_helpers/radiation.dm | 4 ++++ code/_onclick/hud/action/action_screen_objects.dm | 1 + code/_onclick/hud/map_view.dm | 2 +- code/_onclick/hud/screen_objects.dm | 4 ++++ code/datums/browser.dm | 4 ++++ code/datums/callback.dm | 4 ++++ code/datums/mind.dm | 4 ++++ code/game/machinery/cloning.dm | 8 ++++++++ code/game/machinery/computer/camera.dm | 1 + code/game/machinery/pointdefense.dm | 4 ++++ .../effects/anomalies/anomalies_bioscrambler.dm | 4 ++++ .../objects/effects/anomalies/anomaly_stats.dm | 2 ++ code/game/objects/effects/client_only_image.dm | 1 + code/game/objects/items.dm | 1 + code/game/objects/items/devices/radio/radio.dm | 1 + code/game/objects/items/devices/tvcamera.dm | 1 + .../admin/view_variables/color_matrix_editor.dm | 1 + code/modules/anomalies/anomaly.dm | 4 ++++ code/modules/catalogue/cataloguer.dm | 1 + code/modules/flufftext/Hallucination.dm | 2 ++ code/modules/flufftext/fake_attacker.dm | 1 + .../gamemaster/event2/events/engineering/blob.dm | 1 + .../integrated_electronics/subtypes/smart.dm | 10 ++++++++++ code/modules/mob/_modifiers/modifiers.dm | 4 ++++ code/modules/mob/living/bot/bot.dm | 6 ++++++ code/modules/mob/living/bot/cleanbot.dm | 14 ++++++++------ .../computers/modular_computer/core.dm | 1 + code/modules/organs/data.dm | 4 ++++ code/modules/research/tg/rdmachines.dm | 1 + code/modules/resleeving/computers.dm | 2 ++ code/modules/resleeving/machines.dm | 12 ++++++++++-- code/modules/shieldgen/emergency_shield.dm | 1 + code/modules/tgui/modules/appearance_changer.dm | 1 + code/modules/tgui/modules/communications.dm | 4 ++++ 34 files changed, 107 insertions(+), 9 deletions(-) diff --git a/code/_helpers/radiation.dm b/code/_helpers/radiation.dm index 51ab59edec..ba5348b4f3 100644 --- a/code/_helpers/radiation.dm +++ b/code/_helpers/radiation.dm @@ -56,6 +56,10 @@ var/list/turfs_to_process var/strength +/datum/radiation_pulse_information/Destroy(force) + . = ..() + source_ref = null + #define MEDIUM_RADIATION_THRESHOLD_RANGE 0.5 #define EXTREME_RADIATION_CHANCE 30 diff --git a/code/_onclick/hud/action/action_screen_objects.dm b/code/_onclick/hud/action/action_screen_objects.dm index a5693439b5..30addd8b24 100644 --- a/code/_onclick/hud/action/action_screen_objects.dm +++ b/code/_onclick/hud/action/action_screen_objects.dm @@ -29,6 +29,7 @@ viewer.update_action_buttons() our_hud = null linked_action = null + last_hovored_ref = null return ..() /atom/movable/screen/movable/action_button/proc/can_use(mob/user) diff --git a/code/_onclick/hud/map_view.dm b/code/_onclick/hud/map_view.dm index e5c0e8ac05..15cf7beaeb 100644 --- a/code/_onclick/hud/map_view.dm +++ b/code/_onclick/hud/map_view.dm @@ -19,7 +19,7 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/map_view_tg) for(var/datum/weakref/client_ref in viewing_clients) hide_from_client(client_ref.resolve()) QDEL_LIST_NULL(popup_plane_masters) - + viewing_clients.Cut() return ..() /atom/movable/screen/map_view_tg/proc/generate_view(map_key) diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index 8142c6c68c..06fd50500b 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -1011,6 +1011,10 @@ var/static/list/ammo_screen_loc_list = list(ui_ammo_hud1, ui_ammo_hud2, ui_ammo_hud3 ,ui_ammo_hud4) var/datum/weakref/our_gun +/atom/movable/screen/ammo/Destroy() + . = ..() + our_gun = null + /atom/movable/screen/ammo/Click() var/mob/user = usr if(!user.checkClickCooldown()) diff --git a/code/datums/browser.dm b/code/datums/browser.dm index de153f9113..59b3a271bf 100644 --- a/code/datums/browser.dm +++ b/code/datums/browser.dm @@ -31,6 +31,10 @@ if (source) src.source_ref = WEAKREF(source) +/datum/browser/Destroy(force) + . = ..() + source_ref = null + /datum/browser/proc/user_deleted(datum/source) SIGNAL_HANDLER user = null diff --git a/code/datums/callback.dm b/code/datums/callback.dm index 68b53ca415..438db0e34a 100644 --- a/code/datums/callback.dm +++ b/code/datums/callback.dm @@ -55,6 +55,10 @@ if(usr) user = WEAKREF(usr) +/datum/callback/Destroy(force) + . = ..() + user = null + /world/proc/ImmediateInvokeAsync(thingtocall, proctocall, ...) set waitfor = FALSE diff --git a/code/datums/mind.dm b/code/datums/mind.dm index f17d77a80f..78a017b323 100644 --- a/code/datums/mind.dm +++ b/code/datums/mind.dm @@ -71,6 +71,10 @@ antag_holder = new ..() +/datum/mind/Destroy(force) + . = ..() + original_character = null + /datum/mind/proc/transfer_to(mob/living/new_character, force = FALSE) if(!istype(new_character)) log_world("## DEBUG: transfer_to(): Some idiot has tried to transfer_to() a non mob/living mob. Please inform Carn") diff --git a/code/game/machinery/cloning.dm b/code/game/machinery/cloning.dm index 579571096f..ee8e05db17 100644 --- a/code/game/machinery/cloning.dm +++ b/code/game/machinery/cloning.dm @@ -55,6 +55,14 @@ default_apply_parts() update_icon() +/obj/machinery/clonepod/Destroy() + for(var/obj/container in containers) + container.forceMove(get_turf(src)) + containers.Cut() + locked = FALSE + go_out() + . = ..() + /obj/machinery/clonepod/proc/set_occupant(var/mob/living/L) SHOULD_NOT_OVERRIDE(TRUE) if(!L) diff --git a/code/game/machinery/computer/camera.dm b/code/game/machinery/computer/camera.dm index fc7dbc3273..6875d661f2 100644 --- a/code/game/machinery/computer/camera.dm +++ b/code/game/machinery/computer/camera.dm @@ -123,6 +123,7 @@ GLOBAL_LIST_EMPTY(entertainment_screens) vis_contents.Cut() QDEL_NULL(pinboard) QDEL_NULL(radio) + showing = null return ..() /obj/machinery/computer/security/telescreen/entertainment/proc/toggle() diff --git a/code/game/machinery/pointdefense.dm b/code/game/machinery/pointdefense.dm index e1704b43d6..05636db6a4 100644 --- a/code/game/machinery/pointdefense.dm +++ b/code/game/machinery/pointdefense.dm @@ -140,6 +140,10 @@ GLOBAL_LIST_BOILERPLATE(pointdefense_turrets, /obj/machinery/pointdefense) default_apply_parts() update_icon() +/obj/machinery/pointdefense/Destroy(force, ...) + . = ..() + engaging = null + /obj/machinery/pointdefense/get_description_interaction() . = ..() if(!id_tag) diff --git a/code/game/objects/effects/anomalies/anomalies_bioscrambler.dm b/code/game/objects/effects/anomalies/anomalies_bioscrambler.dm index 9c5562ca0f..4f93018d60 100644 --- a/code/game/objects/effects/anomalies/anomalies_bioscrambler.dm +++ b/code/game/objects/effects/anomalies/anomalies_bioscrambler.dm @@ -20,6 +20,10 @@ . = ..() pursuit_target = WEAKREF(find_nearest_target()) +/obj/effect/anomaly/bioscrambler/Destroy() + . = ..() + pursuit_target = null + /obj/effect/anomaly/bioscrambler/anomalyEffect(seconds_per_tick) . = ..() if(stats) diff --git a/code/game/objects/effects/anomalies/anomaly_stats.dm b/code/game/objects/effects/anomalies/anomaly_stats.dm index 0174b331ed..47e2cf1480 100644 --- a/code/game/objects/effects/anomalies/anomaly_stats.dm +++ b/code/game/objects/effects/anomalies/anomaly_stats.dm @@ -31,6 +31,8 @@ /datum/anomaly_stats/Destroy(force) QDEL_NULL(modifier) + attached_anomaly = null + attached_harvester = null return ..() /datum/anomaly_stats/proc/randomize_particle_types() diff --git a/code/game/objects/effects/client_only_image.dm b/code/game/objects/effects/client_only_image.dm index 526dba2a8b..303cd74d54 100644 --- a/code/game/objects/effects/client_only_image.dm +++ b/code/game/objects/effects/client_only_image.dm @@ -15,6 +15,7 @@ var/client/C = CW?.resolve() if(C) C.images -= src + clients.Cut() // Mostly for motion echos, but someone will probably find another use for it... So parent type gets it instead! /image/client_only/proc/place_from_root(var/turf/At) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 1351d4537c..6d2709c3ff 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -168,6 +168,7 @@ /obj/item/Destroy() d_stage_overlay = null + exploit_for = null if(item_tf_spawn_allowed) GLOB.item_tf_spawnpoints -= src if(ismob(loc)) diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index 7b1edade44..cdfe071341 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -114,6 +114,7 @@ SSradio.remove_object(src, frequency) for (var/ch_name in channels) SSradio.remove_object(src, GLOB.radiochannels[ch_name]) + bs_tx_weakref = null return ..() /obj/item/radio/proc/recalculateChannels() diff --git a/code/game/objects/items/devices/tvcamera.dm b/code/game/objects/items/devices/tvcamera.dm index fac5d6e678..546aaa11ef 100644 --- a/code/game/objects/items/devices/tvcamera.dm +++ b/code/game/objects/items/devices/tvcamera.dm @@ -24,6 +24,7 @@ qdel(radio) camera = null radio = null + showing = null . = ..() /obj/item/tvcamera/examine() diff --git a/code/modules/admin/view_variables/color_matrix_editor.dm b/code/modules/admin/view_variables/color_matrix_editor.dm index 3295ac41d0..99b15c3906 100644 --- a/code/modules/admin/view_variables/color_matrix_editor.dm +++ b/code/modules/admin/view_variables/color_matrix_editor.dm @@ -28,6 +28,7 @@ /datum/color_matrix_editor/Destroy(force) QDEL_NULL(proxy_view) + target = null return ..() /datum/color_matrix_editor/tgui_state(mob/user) diff --git a/code/modules/anomalies/anomaly.dm b/code/modules/anomalies/anomaly.dm index 76a874e5cf..76ba207049 100644 --- a/code/modules/anomalies/anomaly.dm +++ b/code/modules/anomalies/anomaly.dm @@ -81,6 +81,10 @@ var/datum/weakref/buffered_anomaly = null +/obj/item/anomaly_scanner/Destroy() + . = ..() + buffered_anomaly = null + /obj/item/anomaly_scanner/attack_self(mob/living/user) . = ..(user) if(.) diff --git a/code/modules/catalogue/cataloguer.dm b/code/modules/catalogue/cataloguer.dm index 0af55e1a33..5f429a5eb7 100644 --- a/code/modules/catalogue/cataloguer.dm +++ b/code/modules/catalogue/cataloguer.dm @@ -63,6 +63,7 @@ GLOBAL_LIST_EMPTY(all_cataloguers) /obj/item/cataloguer/Destroy() GLOB.all_cataloguers -= src displayed_data = null + partial_scanned = null return ..() /obj/item/cataloguer/update_icon() diff --git a/code/modules/flufftext/Hallucination.dm b/code/modules/flufftext/Hallucination.dm index 20f40cde10..fd4ce615d9 100644 --- a/code/modules/flufftext/Hallucination.dm +++ b/code/modules/flufftext/Hallucination.dm @@ -31,6 +31,8 @@ Gunshots/explosions/opening doors/less rare audio (done) if(halitem.len) remove_hallucination_item() our_human = null + halbody = null + halimage = null . = ..() /datum/component/hallucinations/proc/make_timer() diff --git a/code/modules/flufftext/fake_attacker.dm b/code/modules/flufftext/fake_attacker.dm index d38de65398..d268680d2b 100644 --- a/code/modules/flufftext/fake_attacker.dm +++ b/code/modules/flufftext/fake_attacker.dm @@ -47,6 +47,7 @@ . = ..() clear_every_clients_images() qdel_all_images() + clients.Cut() /obj/effect/fake_attacker/proc/create_images_from(var/atom/clone) SHOULD_NOT_OVERRIDE(TRUE) diff --git a/code/modules/gamemaster/event2/events/engineering/blob.dm b/code/modules/gamemaster/event2/events/engineering/blob.dm index e4670cc381..85a0f13842 100644 --- a/code/modules/gamemaster/event2/events/engineering/blob.dm +++ b/code/modules/gamemaster/event2/events/engineering/blob.dm @@ -122,6 +122,7 @@ var/obj/structure/blob/core/B = weakref.resolve() if(istype(B)) qdel(B) + blobs.Cut() /datum/event2/event/blob/announce() if(!ended) // Don't announce if the blobs die early. diff --git a/code/modules/integrated_electronics/subtypes/smart.dm b/code/modules/integrated_electronics/subtypes/smart.dm index 23cc3080b6..9a25e48267 100644 --- a/code/modules/integrated_electronics/subtypes/smart.dm +++ b/code/modules/integrated_electronics/subtypes/smart.dm @@ -55,6 +55,11 @@ var/turf/last_known_position = null var/datum/weakref/last_target = null +/obj/item/integrated_circuit/smart/targeted_pathfinder/Destroy() + . = ..() + last_known_position = null + last_target = null + /obj/item/integrated_circuit/smart/targeted_pathfinder/do_work() var/datum/integrated_io/I = inputs[1] set_pin_data(IC_OUTPUT, 1, null) @@ -131,6 +136,11 @@ var/turf/last_known_position = null var/datum/weakref/last_target = null +/obj/item/integrated_circuit/smart/pathfinding_locomotion/Destroy() + . = ..() + last_known_position = null + last_target = null + /obj/item/integrated_circuit/smart/pathfinding_locomotion/do_work() var/datum/integrated_io/I = inputs[1] diff --git a/code/modules/mob/_modifiers/modifiers.dm b/code/modules/mob/_modifiers/modifiers.dm index 75cbaeb1c5..0929176196 100644 --- a/code/modules/mob/_modifiers/modifiers.dm +++ b/code/modules/mob/_modifiers/modifiers.dm @@ -72,6 +72,10 @@ origin = WEAKREF(holder) ..() +/datum/modifier/Destroy(force) + . = ..() + origin = null + // Checks if the modifier should be allowed to be applied to the mob before attaching it. // Override for special criteria, e.g. forbidding robots from receiving it. /datum/modifier/proc/can_apply(var/mob/living/L, var/suppress_output = FALSE) diff --git a/code/modules/mob/living/bot/bot.dm b/code/modules/mob/living/bot/bot.dm index 3af19c5dbc..f10b7fdc0d 100644 --- a/code/modules/mob/living/bot/bot.dm +++ b/code/modules/mob/living/bot/bot.dm @@ -64,6 +64,12 @@ update_icons() //VOREstation edit - overlay runtime fix default_language = GLOB.all_languages[LANGUAGE_GALCOM] //VOREstation edit - runtime fix +/mob/living/bot/Destroy() + . = ..() + ignore_list.Cut() + patrol_path.Cut() + target_path.Cut() + /mob/living/bot/Life() ..() if(health <= 0) diff --git a/code/modules/mob/living/bot/cleanbot.dm b/code/modules/mob/living/bot/cleanbot.dm index 610aeb5958..d19a4701fd 100644 --- a/code/modules/mob/living/bot/cleanbot.dm +++ b/code/modules/mob/living/bot/cleanbot.dm @@ -39,12 +39,14 @@ if(spray_blood && prob(5)) // Make a big mess visible_message("Something flies out of [src]. It seems to be acting oddly.") - var/obj/effect/decal/cleanable/blood/gibs/gib = new /obj/effect/decal/cleanable/blood/gibs(loc) - // TODO - I have a feeling weakrefs will not work in ignore_list, verify this ~Leshana - var/datum/weakref/g = WEAKREF(gib) - ignore_list += g - spawn(600) - ignore_list -= g + var/obj/effect/decal/cleanable/blood/gibs/gib = new /obj/effect/decal/cleanable/blood/gibs(get_turf(src)) + ignore_list += gib + addtimer(CALLBACK(src,PROC_REF(clear_ignored_gib), gib), 1 MINUTE, TIMER_DELETE_ME) + +/mob/living/bot/cleanbot/proc/clear_ignored_gib(var/obj/gibref) + SHOULD_NOT_OVERRIDE(TRUE) + PRIVATE_PROC(TRUE) + ignore_list -= gibref /mob/living/bot/cleanbot/handlePanic() // Speed modification based on alert level. . = 0 diff --git a/code/modules/modular_computers/computers/modular_computer/core.dm b/code/modules/modular_computers/computers/modular_computer/core.dm index 801b30c372..3709761dec 100644 --- a/code/modules/modular_computers/computers/modular_computer/core.dm +++ b/code/modules/modular_computers/computers/modular_computer/core.dm @@ -58,6 +58,7 @@ for(var/obj/item/computer_hardware/CH in src.get_all_components()) uninstall_component(null, CH) qdel(CH) + paired_uavs.Cut() return ..() /obj/item/modular_computer/emag_act(var/remaining_charges, var/mob/user) diff --git a/code/modules/organs/data.dm b/code/modules/organs/data.dm index af2eee5e16..41f6316f30 100644 --- a/code/modules/organs/data.dm +++ b/code/modules/organs/data.dm @@ -17,6 +17,10 @@ var/list/skin_color var/list/hair_color +/datum/organ_data/Destroy(force) + . = ..() + species = null + /datum/organ_data/proc/setup_from_dna(var/datum/dna/dna) SHOULD_NOT_OVERRIDE(TRUE) // Prosfab uses default dna to get vars, lets respect that still diff --git a/code/modules/research/tg/rdmachines.dm b/code/modules/research/tg/rdmachines.dm index dc399c8817..6bbd902b0f 100644 --- a/code/modules/research/tg/rdmachines.dm +++ b/code/modules/research/tg/rdmachines.dm @@ -29,6 +29,7 @@ log_research("[src] disconnected from techweb [stored_research] (destroyed).") stored_research = null QDEL_NULL(wires) + loaded_item = null return ..() /obj/machinery/rnd/tgui_status(mob/user) diff --git a/code/modules/resleeving/computers.dm b/code/modules/resleeving/computers.dm index 2aae982344..36902bb5fc 100644 --- a/code/modules/resleeving/computers.dm +++ b/code/modules/resleeving/computers.dm @@ -45,6 +45,8 @@ /obj/machinery/computer/transhuman/resleeving/Destroy() releasepods() + current_br = null + current_mr = null return ..() /obj/machinery/computer/transhuman/resleeving/proc/updatemodules() diff --git a/code/modules/resleeving/machines.dm b/code/modules/resleeving/machines.dm index 9f89e60b75..c7787e46bb 100644 --- a/code/modules/resleeving/machines.dm +++ b/code/modules/resleeving/machines.dm @@ -154,6 +154,10 @@ RefreshParts() update_icon() +/obj/machinery/transhuman/synthprinter/Destroy() + current_br = null + . = ..() + /obj/machinery/transhuman/synthprinter/RefreshParts() //Scanning modules reduce burn rating by 15 each @@ -315,6 +319,10 @@ RefreshParts() update_icon() +/obj/machinery/transhuman/resleever/Destroy() + . = ..() + + /obj/machinery/transhuman/resleever/proc/set_occupant(var/mob/living/carbon/human/H) SHOULD_NOT_OVERRIDE(TRUE) if(!H) @@ -512,7 +520,7 @@ playsound(src, 'sound/machines/medbayscanner1.ogg', 100, 1) // Play our sound at the end of the mind injection! return 1 -/obj/machinery/transhuman/resleever/proc/go_out(var/mob/M) +/obj/machinery/transhuman/resleever/proc/go_out() var/mob/living/carbon/human/occupant = get_occupant() if(!occupant) return @@ -541,7 +549,7 @@ set src in oview(1) if(usr.stat != 0) return - src.go_out(usr) + go_out() add_fingerprint(usr) return diff --git a/code/modules/shieldgen/emergency_shield.dm b/code/modules/shieldgen/emergency_shield.dm index d52b50ef20..fc86da3f74 100644 --- a/code/modules/shieldgen/emergency_shield.dm +++ b/code/modules/shieldgen/emergency_shield.dm @@ -41,6 +41,7 @@ var/obj/machinery/shieldgen/SG = our_owner.resolve() if(SG) SG.deployed_shields -= src + our_owner = null . = ..() /obj/machinery/shield/attackby(obj/item/W as obj, mob/user as mob) diff --git a/code/modules/tgui/modules/appearance_changer.dm b/code/modules/tgui/modules/appearance_changer.dm index 7aebff0381..53f2c1a16c 100644 --- a/code/modules/tgui/modules/appearance_changer.dm +++ b/code/modules/tgui/modules/appearance_changer.dm @@ -1140,6 +1140,7 @@ if(DC) DC.selected_record = FALSE DC.designer_gui = null // no hardrefs + linked_body_design_console = null . = ..() /datum/tgui_module/appearance_changer/body_designer/proc/make_fake_owner() diff --git a/code/modules/tgui/modules/communications.dm b/code/modules/tgui/modules/communications.dm index 0680b9f224..afbd8a5c24 100644 --- a/code/modules/tgui/modules/communications.dm +++ b/code/modules/tgui/modules/communications.dm @@ -44,6 +44,10 @@ crew_announcement = new() crew_announcement.newscast = TRUE +/datum/tgui_module/communications/Destroy(force) + . = ..() + ATC = null + /datum/tgui_module/communications/tgui_interact(mob/user, datum/tgui/ui) if(using_map && !(get_z(user) in using_map.contact_levels)) to_chat(user, span_danger("Unable to establish a connection: You're too far away from the station!"))