Mercurial > wow > kbf
diff KBF.lua @ 6:bc661466f10c
use deferred processing of unit_aura in order to avoid race conditions with the attributes of the secure frames
author | Chris Mellon <arkanes@gmai.com> |
---|---|
date | Tue, 12 Oct 2010 18:14:06 -0500 |
parents | 43340216545c |
children | 31048236391d |
line wrap: on
line diff
--- a/KBF.lua Tue Oct 12 17:49:28 2010 -0500 +++ b/KBF.lua Tue Oct 12 18:14:06 2010 -0500 @@ -26,22 +26,24 @@ function kbf:OnUpdate() for idx=1,99 do local frame = self.secureFrame:GetAttribute("child"..idx) - if not (frame and frame.expirationTime) then break end - local remaining = frame.expirationTime - GetTime() - remaining = math.max(0, remaining) - local perc = remaining / frame.duration - frame.timertext:SetText(self:FormatTimeText(remaining)) - frame.statusbar:SetValue(remaining) + if not frame then break end + if self.dirty then + local unit = self.secureFrame:GetAttribute("unit") + self:BindBarToBuff(frame, unit) + elseif frame.expirationTime then + local remaining = frame.expirationTime - GetTime() + remaining = math.max(0, remaining) + local perc = remaining / frame.duration + frame.timertext:SetText(self:FormatTimeText(remaining)) + frame.statusbar:SetValue(remaining) + end end + self.dirty = nil end function kbf:UNIT_AURA(event, unit) if unit ~= self.secureFrame:GetAttribute("unit") then return end - for idx=1,99 do - local frame = self.secureFrame:GetAttribute("child"..idx) - if not frame then break end - self:BindBarToBuff(frame, unit) - end + self.dirty = true end function kbf:BindBarToBuff(parentFrame, unit) @@ -60,7 +62,7 @@ end parentFrame.timertext:SetText(self:FormatTimeText(duration)) -- store duration information - if duration > 0 then + if duration and duration > 0 then parentFrame.expirationTime = expirationTime parentFrame.duration = duration parentFrame.statusbar:SetMinMaxValues(0, duration)