HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Handle destruction unlinking

08-21-2006, 09:13 AM#1
Daelin
I was just wondering if it is safe to destroy a handle to which other values are linked. Example:

Collapse JASS:
local trigger t = CreateTrigger()
call SetHandleReal(t, "value", 1.00)
call DestroyTrigger(t)
set t = null

Will this leak for example because I didn't flush the trigger, or it is enough to destroy it so that all linked values are broken?

~Daelin
08-21-2006, 09:25 AM#2
DioD
You cannot link anything to handle.

Inside cache Handle ID stored as string and not monitored by game engine.

Next trigger will take empty ID and all "linked" data.

Using this exploit you can create auto cleaner functions.

Just link some boolean value to handle for monitor its type and usage.
08-21-2006, 01:00 PM#3
UnMi
Quote:
Originally Posted by Daelin
I was just wondering if it is safe to destroy a handle to which other values are linked. Example:

Collapse JASS:
local trigger t = CreateTrigger()
call SetHandleReal(t, "value", 1.00)
call DestroyTrigger(t)
set t = null

Will this leak for example because I didn't flush the trigger, or it is enough to destroy it so that all linked values are broken?
I'm sure this would leak, because what you destroyed is not the value stored in Gamecache, which most likely
Collapse JASS:
call StoreReal(game_cache(), I2S(HANDLE_INTEGER)), name, value)
I don't think the HANDLE_INTEGER used as "cathegory" would care what happens to the handle you used. All that is left will be a value that cannot be retrieved nor be flushed anymore, because trying to do so would cause a crash.
08-21-2006, 01:25 PM#4
Anitarf
You should alwasy clear attached variables before destroying the handle.
08-21-2006, 01:46 PM#5
DioD
Using direct arrays much more easy and faster.
I dont know why all using cache...
08-21-2006, 02:00 PM#6
aquilla
the value will be stored in the cache ofc "leaking", but why do you need to store a value and then destroy the trigger? :o
08-21-2006, 02:01 PM#7
UnMi
Quote:
Using direct arrays much more easy and faster.
I dont know why all using cache...
...
Collapse JASS:
call GetStoredInteger(GetUnitName(UNIT_1),"Skill")
There, happy arrraying.
08-21-2006, 03:10 PM#8
Daelin
Quote:
Originally Posted by aquilla
the value will be stored in the cache ofc "leaking", but why do you need to store a value and then destroy the trigger? :o

I am making a custom TriggerRegisterUnitEvent (you'll see pretty soon what) and I wanted to avoid using a custom DestroyTrigger() for it, to avoid confusions. Hmm... I guess I'll have to find a way to solve that. Thanks for the tips guys. It's just the answer I expected, dunno why I even thought that destroying the handle would solve the problem! :)

~Daelin
08-21-2006, 04:31 PM#9
Vexorian
direct arrays are static. cache is dynamic, there is no better reason.

UnMi : He meant that arrays are faster in game than gamecache.

Daelin, your answer is that you should always make sure to flush everything related to a handle before destroying the handle Else the screen will explode in your face.