| 04-29-2009, 12:36 PM | #1 |
Hi all, I maintain a map that uses text tag to show customized spell damage. I set-up a routine that looks like this Code:
function ShowTextTag_Destroy takes nothing returns nothing local timer tm = GetExpiredTimer() call DestroyTextTag(GetAttachedTextTag(tm, "tt")) call Flush(tm) call DestroyTimer(tm) set tm = null endfunction function ShowTextTag takes string s, unit whichUnit, real zOffset, real size, real red, real green, real blue, real transparency, real duration, boolean show returns nothing local texttag tt = null local timer tm = null set tm = CreateTimer() set tt = CreateTextTagUnitBJ(s, whichUnit, zOffset, size, red, green, blue, transparency) call SetTextTagVisibility(tt, BooleanTertiaryOp(IsUnitVisible(whichUnit, GetLocalPlayer()), show, false)) call AttachHandle(tm, "tt", tt) call SetTextTagSuspended(tt, true) call SetTextTagVelocityBJ(tt, 64, 90) call SetTextTagPermanent(tt, false) call SetTextTagLifespan(tt, duration) call SetTextTagFadepoint(tt, duration/3*2) call SetTextTagSuspended(tt, false) call TimerStart(tm, duration*1.3, false, function ShowTextTag_Destroy) set tt = null set tm = null endfunction I always thought that it's the coder's responsibility to remove the text tag but by looking others' code I see that they do not call DestroyTextTag() when the text tag is non-permanent. I'd like to seek confirmation that it is safe that I do not have to deal with DestroyText() explicitly if the text tag has a finite life span. I am not too sure if the text tag leaks in the absence of DestroyText() call. Thanks. |
| 04-29-2009, 01:59 PM | #2 |
No. SetTextTagLifespan already destroys the handle. |
