Mob Ref Cleanup Part 3 (#22599)

Part 3 of the Mob Destroy Refactor, this time going through the entire
list of every ref stored up to a mob/human, and (attempting) to verify
and cleanup every possible circular ref. This PR also fixes some
mistakes made with cleaning up UI elements, namely that tgui's really
don't like it when you qdel them, and screen objects also weren't always
clearing their own references if Qdel'ed directly. There were several
niche situations too where circle refs might be retained by a mob. I
also found an issue where static lights were only cleaned up on
/atom/movable/ but actually existed farther up the chain on /atom. I
don't know if any /atoms that aren't /atom/movable ever get static
lights, but the fact that they can be needs to be correctly accounted
for.

I can't possibly have gotten all of them, but this is every single one I
could find after 3 hours of work.
This commit is contained in:
VMSolidus
2026-06-11 10:47:56 +00:00
committed by GitHub
parent 11a9a2d644
commit 1fbead50af
15 changed files with 95 additions and 54 deletions
+17 -2
View File
@@ -54,6 +54,8 @@
QDEL_NULL(ability_master)
QDEL_NULL(zone_sel)
if (length(machine?.climbers))
machine.climbers -= src
machine = null
client_colors = null
@@ -61,6 +63,7 @@
pinned?.Cut()
QDEL_LIST(embedded)
languages?.Cut()
holo?.clear_holo(src)
holo = null
l_hand = null
r_hand = null
@@ -104,11 +107,23 @@
QDEL_LIST(click_handlers)
vr_mob = null
old_mob = null
if (lastattacker && lastattacker.lastattacked == src)
lastattacker.lastattacked = null
if (lastattacked && lastattacked.lastattacker == src)
lastattacked.lastattacker = null
lastattacker = null
lastattacked = null
QDEL_NULL(pointing_effect)
QDEL_LIST(open_nanouis)
QDEL_LIST(tgui_open_uis)
// Cleanup for all UIs belonging to the client.
// For performance reasons we check the length of the lists first since the lists can potentially either be null or empty.
// But it's also plausible that they might contain null values, and while their aggressive checking means any valid entry in the list
// is guaranteed to be of type /datum/tgui, null entries in the list can potentially exist and will pass the as anything typecast.
if (length(tgui_open_uis))
for (var/datum/tgui/ui as anything in tgui_open_uis)
ui?.close()
tgui_open_uis.Cut()
QDEL_NULL(narsimage)
QDEL_NULL(narglow)
QDEL_NULL(riftimage)