From 68d182b576239b60f4223731eea135f629e0d78b Mon Sep 17 00:00:00 2001 From: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Date: Thu, 5 Sep 2024 01:55:38 +0000 Subject: [PATCH] Moves deletion for dreamluau objects to happen at the very end of the Destroy proc. (#86066) ## About The Pull Request As the title says ## Why It's Good For The Game Dreamluau objects should only really be nulled out right before deletion handling is complete, since it makes logical sense for lua to have a handle on these objects up until they're queued for deletion. It's slightly different from weakrefs in the fact that a weakref is not going to handle signals, but a lua script can, so it makes sense for the nulling out to happen after ECS cleanup is complete. No changelog necessary since it's not fixing any particular bug Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com> --- code/datums/datum.dm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/datums/datum.dm b/code/datums/datum.dm index 3361229b92e..a4169004fc9 100644 --- a/code/datums/datum.dm +++ b/code/datums/datum.dm @@ -111,9 +111,6 @@ tag = null datum_flags &= ~DF_USE_TAG //In case something tries to REF us weak_reference = null //ensure prompt GCing of weakref. - if(!(datum_flags & DF_STATIC_OBJECT)) - DREAMLUAU_CLEAR_REF_USERDATA(vars) // vars ceases existing when src does, so we need to clear any lua refs to it that exist. - DREAMLUAU_CLEAR_REF_USERDATA(src) if(_active_timers) var/list/timers = _active_timers @@ -145,6 +142,10 @@ _clear_signal_refs() //END: ECS SHIT + if(!(datum_flags & DF_STATIC_OBJECT)) + DREAMLUAU_CLEAR_REF_USERDATA(vars) // vars ceases existing when src does, so we need to clear any lua refs to it that exist. + DREAMLUAU_CLEAR_REF_USERDATA(src) + return QDEL_HINT_QUEUE ///Only override this if you know what you're doing. You do not know what you're doing