From a5b90458300d29f060dc4bd380c2844f96d0c4b2 Mon Sep 17 00:00:00 2001 From: Parnic Date: Wed, 9 Sep 2009 01:31:02 +0000 Subject: [PATCH] - potential fix for user-submitted totem bug: http://www.wowace.com/addons/ice-hud/tickets/29-error-when-dismissing-totems/ --- modules/Totems.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/Totems.lua b/modules/Totems.lua index 9bd0bf3..281a324 100644 --- a/modules/Totems.lua +++ b/modules/Totems.lua @@ -344,12 +344,14 @@ function Totems.prototype:CreateTotem(i, name) return end local haveTotem, name, startTime, duration, icon = GetTotemInfo(i) + local bWasNewFrame = false if (not self.frame.graphical[i]) then self.frame.graphical[i] = CreateFrame("StatusBar", nil, self.frame) self.frame.graphical[i].cd = CreateFrame("Cooldown", nil, self.frame.graphical[i], "CooldownFrameTemplate") self.frame.graphical[i].shine = self.frame.graphical[i]:CreateTexture(nil, "OVERLAY") self.frame.graphical[i]:SetStatusBarTexture(icon) + bWasNewFrame = true end self.frame.graphical[i]:SetFrameStrata("BACKGROUND") @@ -387,11 +389,14 @@ function Totems.prototype:CreateTotem(i, name) self.frame.graphical[i].slot = i; self.frame.graphical[i]:SetScript("OnEnter", function(button) GameTooltip:SetOwner(button); GameTooltip:SetTotem(button.slot) end) self.frame.graphical[i]:SetScript("OnLeave", function() GameTooltip:Hide() end) - self.frame.graphical[i]:HookScript("OnMouseUp", function (self, mouseButton) - if ( mouseButton == "RightButton" ) then - DestroyTotem(self.slot); - end - end) + -- it looks like HookScript will continue to add handlers every time instead of replacing them like SetScript + if (bWasNewFrame) then + self.frame.graphical[i]:HookScript("OnMouseUp", function (self, mouseButton) + if ( mouseButton == "RightButton" ) then + DestroyTotem(self.slot); + end + end) + end end