mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-21 13:05:36 +01:00
[MIRROR] Add weakref support to qdel (#2742)
* Add weakref support to qdel (#56171) qdel() should allow usage of weakrefs to avoid harddels on long duration qdel_in usage * Add weakref support to qdel Co-authored-by: spookydonut <github@spooksoftware.com>
This commit is contained in:
@@ -284,15 +284,21 @@ SUBSYSTEM_DEF(garbage)
|
||||
///
|
||||
/// Datums passed to this will be given a chance to clean up references to allow the GC to collect them.
|
||||
/proc/qdel(datum/D, force=FALSE, ...)
|
||||
if(isweakref(D))
|
||||
var/datum/weakref/weakref = D
|
||||
D = weakref.resolve()
|
||||
if(!D)
|
||||
return
|
||||
|
||||
if(!istype(D))
|
||||
del(D)
|
||||
return
|
||||
|
||||
var/datum/qdel_item/I = SSgarbage.items[D.type]
|
||||
if (!I)
|
||||
I = SSgarbage.items[D.type] = new /datum/qdel_item(D.type)
|
||||
I.qdels++
|
||||
|
||||
|
||||
if(isnull(D.gc_destroyed))
|
||||
if (SEND_SIGNAL(D, COMSIG_PARENT_PREQDELETED, force)) // Give the components a chance to prevent their parent from being deleted
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user