Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
porch-wow opened this issue Sep 1, 2024 · 1 comment

Comments

@porch-wow
Copy link

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.

@porch-wow
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant