- fix for custom modules generating a ton of errors if they're disabled while active (such as when changing profiles). there is still a bug where they stop running their updates like they're supposed to, but this will at least take care of the error spam

This commit is contained in:
Parnic
2010-09-21 13:50:35 +00:00
parent 631f3dd734
commit 1fa11ea3dd
3 changed files with 33 additions and 21 deletions

View File

@ -61,6 +61,12 @@ function IceBarElement.prototype:Enable()
self:RegisterFontStrings()
end
function IceBarElement.prototype:Disable(core)
IceBarElement.super.prototype.Disable(self, core)
self.frame:SetScript("OnUpdate", nil)
end
function IceBarElement.prototype:RegisterFontStrings()
if DogTag ~= nil and self.moduleSettings ~= nil and self.moduleSettings.usesDogTagStrings then

View File

@ -25,7 +25,6 @@ IceCore.prototype.defaults = {}
IceCore.prototype.settings = nil
IceCore.prototype.IceHUDFrame = nil
IceCore.prototype.updatees = {}
IceCore.prototype.updatee_count = 0
IceCore.prototype.update_elapsed = 0
IceCore.prototype.elements = {}
IceCore.prototype.enabled = nil
@ -295,6 +294,13 @@ function IceCore.prototype:Disable(userToggle)
self.IceHUDFrame:Hide()
self:EmptyUpdates()
for i=#self.elements, 1, -1 do
if self.elements[i].moduleSettings.customBarType ~= nil then
table.remove(self.elements, i)
end
end
self.enabled = false
end
@ -661,8 +667,9 @@ function IceCore.prototype:SetUpdatePeriod(period)
end
-- For elements that want to receive updates even when hidden
function IceCore.HandleUpdates(frame, elapsed)
function IceCore.HandleUpdates()
local update_period = IceHUD.IceCore:UpdatePeriod()
local elapsed = 1 / GetFramerate()
IceCore.prototype.update_elapsed = IceCore.prototype.update_elapsed + elapsed
if (IceCore.prototype.update_elapsed > update_period) then
for frame, func in pairs(IceCore.prototype.updatees)
@ -678,23 +685,18 @@ function IceCore.HandleUpdates(frame, elapsed)
end
function IceCore.prototype:RequestUpdates(frame, func)
if self.updatees[frame] then
if not func then
self.updatee_count = self.updatee_count - 1
end
else
if func then
self.updatee_count = self.updatee_count + 1
end
self.updatees[frame] = func
local count = 0
for k,v in pairs(self.updatees) do
count = count + 1
end
if (self.updatee_count == 0) then
if (count == 0) then
self.IceHUDFrame:SetScript("OnUpdate", nil)
else
self.IceHUDFrame:SetScript("OnUpdate", IceCore.HandleUpdates)
end
self.updatees[frame] = func
end
function IceCore.prototype:IsUpdateSubscribed(frame)
@ -704,7 +706,6 @@ end
function IceCore.prototype:EmptyUpdates()
self.IceHUDFrame:SetScript("OnUpdate", nil)
self.updatees = {}
self.updatee_count = 0
end
-------------------------------------------------------------------------------

View File

@ -33,7 +33,7 @@ function IceCustomBar.prototype:Enable(core)
self:Show(true)
self.unit = self.moduleSettings.myUnit
self:CheckShouldSubscribe()
self:ConditionalSubscribe()
self:UpdateCustomBar(self.unit)
@ -45,14 +45,18 @@ function IceCustomBar.prototype:Enable(core)
end
end
function IceCustomBar.prototype:CheckShouldSubscribe()
if self.unit == "focustarget" or self.unit == "pettarget" then
function IceCustomBar.prototype:ConditionalSubscribe()
if self:ShouldAlwaysSubscribe() then
IceHUD.IceCore:RequestUpdates(self.frame, function() self:UpdateCustomBar() end)
else
IceHUD.IceCore:RequestUpdates(self.frame, nil)
end
end
function IceCustomBar.prototype:ShouldAlwaysSubscribe()
return self.unit == "focustarget" or self.unit == "pettarget"
end
function IceCustomBar.prototype:TargetChanged()
IceCustomBar.super.prototype.TargetChanged(self)
@ -185,7 +189,7 @@ function IceCustomBar.prototype:GetOptions()
set = function(info, v)
self.moduleSettings.myUnit = info.option.values[v]
self.unit = info.option.values[v]
self:CheckShouldSubscribe()
self:ConditionalSubscribe()
self:Redraw()
self:UpdateCustomBar(self.unit)
IceHUD:NotifyOptionsChange()
@ -536,9 +540,8 @@ function IceCustomBar.prototype:UpdateCustomBar(unit, fromUpdate)
end
if self.auraEndTime ~= nil and (self.auraEndTime == 0 or self.auraEndTime >= now) then
if not fromUpdate and not IceHUD.IceCore:IsUpdateSubscribed(self.frame) then
if not self:ShouldAlwaysSubscribe() and not fromUpdate and not IceHUD.IceCore:IsUpdateSubscribed(self.frame) then
IceHUD.IceCore:RequestUpdates(self.frame, function() self:UpdateCustomBar(self.unit, true) end)
--self.frame:SetScript("OnUpdate", function() self:UpdateCustomBar(self.unit, true) end)
end
self:Show(true)
@ -555,7 +558,9 @@ function IceCustomBar.prototype:UpdateCustomBar(unit, fromUpdate)
else
self:UpdateBar(0, "undef")
self:Show(false)
self.frame:SetScript("OnUpdate", nil)
if not self:ShouldAlwaysSubscribe() then
IceHUD.IceCore:RequestUpdates(self.frame, nil)
end
end
if (remaining ~= nil) then