How is this addon tainting?

by Baudzilla | 03/10/2007 10:26:01

Baudzilla

A small addon I wrote is frequently causing taint and I can't figure out how. It is an addon for displaying a timer on cooldown frames. If anyone can figure this out, I would really appreciate it. Here's the XML part:

<Script file="BaudActionTimer.lua"/>
<Frame name="BaudActionTimerTemplate" setAllPoints="true" virtual="true">
<Layers>
<Layer level="OVERLAY">
<FontString name="$parentTextLarge" inherits="MasterFont" font="Fonts\FRIZQT__.TTF">
<FontHeight><AbsValue val="15"/></FontHeight>
<Color r=".8" g=".8" b="0"/>
<Anchors><Anchor point="CENTER"/></Anchors>
</FontString>
<FontString name="$parentTextSmall" inherits="MasterFont" font="Fonts\FRIZQT__.TTF">
<FontHeight><AbsValue val="12"/></FontHeight>
<Color r=".8" g=".8" b="0"/>
<Anchors><Anchor point="CENTER"/></Anchors>
</FontString>
</Layer>
</Layers>
<Scripts>
<OnUpdate>
BaudActionTimer_OnUpdate();
</OnUpdate>
<OnSizeChanged>
BaudActionTimer_OnSizeChanged();
</OnSizeChanged>
</Scripts>
</Frame>


And here is the lua part:


hooksecurefunc("CooldownFrame_SetTimer",function(Co
oldown, Start, Duration, Enable)
local Timer = getglobal(Cooldown:GetName().."Time");
if not Timer then
Timer = CreateFrame("Frame",Cooldown:GetName().."Time",Coo
ldown,"BaudActionTimerTemplate");
end
Timer.Start = Start;
Timer.Duration = Duration;
end);

function BaudActionTimer_OnSizeChanged()
this:SetScale(this:GetParent():GetWidth() / 36);
end

--Note that this will only show as long as the cooldown is shown
function BaudActionTimer_OnUpdate()
if not this.Duration then
return;
end
local Large, Small = getglobal(this:GetName().."TextLarge"), getglobal(this:GetName().."TextSmall");
local Remain = ceil(this.Duration-(GetTime()-this.Start)+1)-1;
if(this.Duration < 4)or(Remain < 0)then
if Large:IsShown()then
Large:Hide();
end
if Small:IsShown()then
Small:Hide();
end
return;
end
if(Remain >= 60)then
if Large:IsShown()then
Large:Hide();
end
Small:SetText(string.format("%d:%.2d",Remain / 60,Remain % 60));
if not Small:IsShown()then
Small:Show();
end
return;
end
if Small:IsShown()then
Small:Hide();
end
Large:SetText(Remain);
if not Large:IsShown()then
Large:Show();
end

by Slouken | 17/10/2007 03:27:18

Slouken

I'm looking into this, thanks!

by Slouken | 18/10/2007 23:20:52

Slouken

Yay, I figured this out!

The text status bar Lua code was assuming that it was being called in response to an event with arg1 and arg2, but it was being called to update frames in response to an event without any arg2. So, the arg2 value it was using was a left over tainted value from a previous event dispatch.

I'm refactoring the text status bar code a bit so it's more resilient to this kind of taint. This will be in the test realm update coming next week.

by Slouken | 20/10/2007 03:27:28

Slouken

This is fixed for next week's PTR update. In the meantime, please post followup here:
Interface action failed because of an AddOn
Hot: Grab one of our RSS feeds to stay updated with what's happening with your class!

Bump! Recently Bumped Threads

 

Blizzard Announcement Recent Blizzard Announcements

 

We suggest