PitBull Unit Frames 4.0

PitBull Unit Frames 4.0

5M Downloads

Totems module: Right-clicking totems to dismiss calls protected function

porch-wow opened this issue ยท 1 comments

commented

Right-clicking on totems calls DestroyTotem, which is a protected function. I fixed it on my end using this:

index 2946466..1ab4ed9 100755
--- a/Totems.bak.lua
+++ b/Totems.lua
@@ -522,7 +522,11 @@ function PitBull4_Totems:BuildFrames(frame)
                -- Main totem slot frame
                elements[i] = {}
                if not elements[i].frame then
-                       elements[i].frame = PitBull4.Controls.MakeButton(ttf)
+                       --elements[i].frame = PitBull4.Controls.MakeButton(ttf)
+                       local f = CreateFrame("Button", "PitBull4_TotemButton_" .. i, ttf, "SecureUnitButtonTemplate")
+                       f:SetAttribute("type", "destroytotem")
+                       f:SetAttribute("totem-slot", TOTEM_ORDER[i])
+                       elements[i].frame = f
                end
                local frm = elements[i].frame

@@ -620,7 +624,7 @@ function PitBull4_Totems:BuildFrames(frame)
                -- Click handling
                -- click handling for destroying single totems
                frm:RegisterForClicks("RightButtonUp")
-               frm:SetScript("OnClick", self.button_scripts.OnClick)
+               --frm:SetScript("OnClick", self.button_scripts.OnClick)
                -- tooltip handling
                frm:SetScript("OnEnter", self.button_scripts.OnEnter)
                frm:SetScript("OnLeave", self.button_scripts.OnLeave)
@@ -1231,4 +1235,4 @@ PitBull4_Totems:SetColorOptionsFunction(function(self)
                db.text_color_per_element = false
                self:UpdateAll()
        end
-end)
\ No newline at end of file
+end)

I didn't test this thoroughly, though, so I'm not sure if there are other implications for using the secure button template. I also didn't really dig into the frame pool implementation, so this doesn't use fetch_control.

commented

Changing the frame to be a secure template directly causes issues in combat, e.g.

3x [ADDON_ACTION_BLOCKED] AddOn 'PitBull4' tried to call the protected function 'PitBull4_Frame_11:SetScale()'.
[string "@!BugGrabber/BugGrabber.lua"]:485: in function <!BugGrabber/BugGrabber.lua:485>
[string "=[C]"]: in function `SetScale'
[string "@PitBull4/UnitFrameLayout.lua"]:1501: in function <PitBull4/UnitFrameLayout.lua:1443>
[string "@PitBull4/UnitFrameLayout.lua"]:1569: in function `UpdateLayout'
[string "@PitBull4/ModuleHandling/Module.lua"]:321: in function `Update'
[string "@PitBull4/ModuleHandling/Module.lua"]:393: in function `?'
[string "@DevTool/Libs/AceTimer-3.0-17/AceTimer-3.0.lua"]:55: in function <...ceDevTool/Libs/AceTimer-3.0/AceTimer-3.0.lua:50>

Locals:
_ = Frame {
}
event = "ADDON_ACTION_BLOCKED"
events = <table> {
}

So a different approach although is probably needed to fix this, rather than my naive one.