mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-22 20:48:56 +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
|
||||
|
||||
@@ -180,7 +180,7 @@
|
||||
QDEL_IN(colour, 11)
|
||||
doomslayer = victim
|
||||
RegisterSignal(src, COMSIG_PARENT_QDELETING, .proc/end_blood_frenzy)
|
||||
QDEL_IN(src, duration)
|
||||
QDEL_IN(WEAKREF(src), duration)
|
||||
|
||||
/obj/effect/mine/pickup/bloodbath/proc/end_blood_frenzy()
|
||||
if(doomslayer)
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
add_overlay("hatch")
|
||||
add_overlay("legs_retracted")
|
||||
addtimer(CALLBACK(src, .proc/startUp), 50)
|
||||
QDEL_IN(src, 8 MINUTES) //Self-destruct after 8 min
|
||||
QDEL_IN(WEAKREF(src), 8 MINUTES) //Self-destruct after 8 min
|
||||
SSeconomy.market_crashing = TRUE
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user