Skip to content

Commit

Permalink
Adds SHOULD_CALL_PARENT to Destroy() (tgstation#45188)
Browse files Browse the repository at this point in the history
Timers, signals, and components need to know when the thing they're 
attached to is getting destroyed or bad things happen. Since any datum 
can make use of these every destroy needs to call parent.
  • Loading branch information
ninjanomnom authored and SpaceManiac committed Jul 16, 2019
1 parent cac3ce8 commit c25459d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions code/controllers/globals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ GLOBAL_REAL(GLOB, /datum/controller/global_vars)

Initialize()

/datum/controller/global_vars/Destroy()
//fuck off kevinz
/datum/controller/global_vars/Destroy(force)
// This is done to prevent an exploit where admins can get around protected vars
SHOULD_CALL_PARENT(0)
return QDEL_HINT_IWILLGC

/datum/controller/global_vars/stat_entry()
Expand Down
1 change: 1 addition & 0 deletions code/datums/datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
* Returns QDEL_HINT_QUEUE
*/
/datum/proc/Destroy(force=FALSE, ...)
SHOULD_CALL_PARENT(1)
tag = null
datum_flags &= ~DF_USE_TAG //In case something tries to REF us
weak_reference = null //ensure prompt GCing of weakref.
Expand Down
1 change: 1 addition & 0 deletions code/datums/position_point_vector.dm
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@

/datum/point/vector/processed/Destroy()
STOP_PROCESSING(SSprojectiles, src)
return ..()

/datum/point/vector/processed/proc/start()
last_process = world.time
Expand Down
8 changes: 6 additions & 2 deletions code/datums/weakrefs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@
/datum/weakref/New(datum/thing)
reference = REF(thing)

/datum/weakref/Destroy()
return QDEL_HINT_LETMELIVE //Let BYOND autoGC thiswhen nothing is using it anymore.
/datum/weakref/Destroy(force)
if(!force)
return QDEL_HINT_LETMELIVE //Let BYOND autoGC thiswhen nothing is using it anymore.
var/datum/target = resolve()
target?.weak_reference = null
return ..()

/datum/weakref/proc/resolve()
var/datum/D = locate(reference)
Expand Down
1 change: 1 addition & 0 deletions code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ GLOBAL_LIST_EMPTY(external_rsc_urls)
return ..()

/client/Destroy()
. = ..() //Even though we're going to be hard deleted there are still some things that want to know the destroy is happening
return QDEL_HINT_HARDDEL_NOW

/client/proc/set_client_age_from_db(connectiontopic)
Expand Down

0 comments on commit c25459d

Please sign in to comment.