* Fixes an odd condition where a frame would stop updating.
James Whitehead II [06-04-07 - 01:39]
* Fixes an odd condition where a frame would stop updating.
diff --git a/PerfectRaid.lua b/PerfectRaid.lua
index f01c8f9..b0b0b52 100644
--- a/PerfectRaid.lua
+++ b/PerfectRaid.lua
@@ -520,13 +520,24 @@ function OnAttributeChanged(frame, name, value)
if name ~= "unit" then return end
local self = PerfectRaid
+
+ -- This code finds all instances of the current frame
+ -- and clears them from the unit table. This is exhaustive
+ -- to ensure nothing is left referencing this frame.
for unit,tbl in pairs(frames) do
if tbl[frame] and frame:GetAttribute("unit") ~= unit then
tbl[frame] = nil
end
end
+ -- If we've been given a unit, instead of nil
if value then
+ -- Register us for frame updates under the correct unit ID.
+ frames[unit] = frames[unit] or {}
+ frames[unit][frame] = true
+
+ -- Use the unitname to check if we need to update config
+ -- even if the unitID changed.
local unitname = UnitName(value)
if not frame.unit then
frame.unit = value
@@ -536,7 +547,8 @@ function OnAttributeChanged(frame, name, value)
return
end
end
-
+
+ -- Set the variables we use to check/clear
frame.unit = value
frame.unitname = unitname
@@ -573,9 +585,6 @@ function OnAttributeChanged(frame, name, value)
frame.status:SetText(nil)
- frames[unit] = frames[unit] or {}
- frames[unit][frame] = true
-
for name,module in self:IterateModules() do
if type(module.ShowButton) == "function" then
module:ShowButton(frame)