WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Moving BuffFrame securely (https://www.wowinterface.com/forums/showthread.php?t=55928)

tehmoku 12-20-17 10:43 AM

Moving BuffFrame securely
 
I use this script to move my BuffFrame closer to the center of the screen.

Code:

hooksecurefunc("BuffFrame_UpdateAllBuffAnchors", function()
        local b = _G["BuffFrame"]
        b:ClearAllPoints()
        b:SetPoint("CENTER", UIParent, "RIGHT", -500, 200)
end)

This causes taint when trying to right-click off the buffs because CancelUnitBuff() is secure. Since I don't want to create an entire buff addon, is there a way of simply changing the anchors of BuffFrame securely so I am able to right-click off my buffs in combat?

Resike 12-20-17 01:14 PM

Lua Code:
  1. -- Player buffs
  2. local b = _G.BuffFrame
  3. b:SetMovable(true)
  4. b:SetUserPlaced(true)
  5. b:ClearAllPoints()
  6. b:SetPoint("TopRight", UIParent, "TopRight", - 204, - 66)
  7. b:SetMovable(false)
  8.  
  9. local moving
  10. hooksecurefunc(BuffFrame, "SetPoint", function(self)
  11.     if moving then
  12.         return
  13.     end
  14.     moving = true
  15.     self:SetMovable(true)
  16.     self:SetUserPlaced(true)
  17.     self:ClearAllPoints()
  18.     self:SetPoint("TopRight", UIParent, "TopRight", - 204, - 66)
  19.     self:SetMovable(false)
  20.     moving = nil
  21. end)
  22.  
  23. -- Consolidated buffs
  24. --[[local c = _G["ConsolidatedBuffs"]
  25. c:ClearAllPoints()
  26. c:SetPoint("TopRight", UIParent, "TopRight", - 204, - 66)
  27. c:SetMovable(true)
  28. c:SetUserPlaced(true)
  29. c:SetMovable(false)
  30. if BuffFrame.numConsolidated == 0 then
  31.     c:Hide()
  32. end]]
  33.  
  34. -- Player debuffs
  35. if DebuffButton_UpdateAnchors then
  36.     hooksecurefunc("DebuffButton_UpdateAnchors", function()
  37.         local d = _G.DebuffButton1
  38.         if d then
  39.             d:SetMovable(true)
  40.             d:SetUserPlaced(true)
  41.             d:ClearAllPoints()
  42.             d:SetPoint("TopRight", BuffFrame, "TopRight", 0, - 180)
  43.             d:SetMovable(false)
  44.         end
  45.     end)
  46. end

Fill the anchors however you would like.

tehmoku 12-20-17 01:53 PM

So, that moves the buffframe how you would expect, and works fine with only my addon enabled. However, when using a different addon called EasyFrames, I get an error for a CancelUnitBuff() attempt in combat. Again, this doesn't happen when it's just my addon enabled--I am able to cancel buffs fine. (In fact, I could with the original code posted.)

I've been planning on writing my own unitframe mod anyway so disabling that addon is fine, but my noob question is this: Is that taint caused by my addon, and is EasyFrames is being blamed for it? From what I can tell, it doesn't handle playerbuffs in the buffframe in any capacity.

I just want to try and make sure my addon isn't the cause of rogue taint to mess up other things down the line.

Here's the error it throws out

Code:

9x [ADDON_ACTION_BLOCKED] AddOn 'EasyFrames' tried to call the protected function 'CancelUnitBuff()'.
!BugGrabber\BugGrabber.lua:573: in function <!BugGrabber\BugGrabber.lua:573>
[C]: in function `CancelUnitBuff'
FrameXML\BuffFrame.lua:280: in function `BuffButton_OnClick'
[string "*:OnClick"]:1: in function <[string "*:OnClick"]:1>

Locals:
InCombatSkipped


jeffy162 12-20-17 03:40 PM

I don't really know, but I would say that you should (maybe) know how the taint system works - which, at best, is ... really wierd. You can't say, with any certainty (from what I understand), which addon really caused the taint. And THAT is really frustrating.

I could be totally wrong about this, and if I am, I apologise for putting this here.

tehmoku 12-20-17 04:04 PM

It seems extremely likely that the code posted is what caused the taint. The interesting thing here, though, is that I can run it without error unless I load the other addon. Functionality is restored completely when I remove my code.

I agree with you though, I need to learn more about the taint system. It's really wonky to me.

jeffy162 12-20-17 04:14 PM

Quote:

Originally Posted by tehmoku (Post 326212)
... the taint system. It's really wonky ...

I would say that that's putting it ... mildly.

Resike 12-20-17 04:28 PM

Quote:

Originally Posted by tehmoku (Post 326212)
It seems extremely likely that the code posted is what caused the taint. The interesting thing here, though, is that I can run it without error unless I load the other addon. Functionality is restored completely when I remove my code.

I agree with you though, I need to learn more about the taint system. It's really wonky to me.

There is no way that the code i posted would taint, if only run once: when your addon is loaeded.

MunkDev 12-21-17 09:26 AM

Taint isn't hard to understand at all. It just means "addon code touched this, so we can't assume execution is safe from here on out". Taint usually spreads by replacing or calling UI functions (implemented in Lua) directly, instead of properly hooking on to functions when they execute instead.
Using widget meta functions (such as SetPoint) doesn't spread taint. E.g:

Lua Code:
  1. -- This will spread taint if BuffFrame:SetPoint() is called in a signed code scope.
  2. local realSetPoint = BuffFrame.SetPoint
  3. function BuffFrame:SetPoint()
  4.     realSetPoint(self, "CENTER", UIParent, "RIGHT", -500, 200)
  5. end
  6.  
  7. -- This will not spread taint at any time, ever.
  8. hooksecurefunc(BuffFrame, "SetPoint", function(self, pnt, relTo, relPnt, x, y)
  9.     if pnt ~= "CENTER" or relPnt ~= "RIGHT" or x ~= -500 then
  10.         self:SetPoint("CENTER", UIParent, "RIGHT", -500, 200)
  11.     end
  12. end)

Resike 12-22-17 07:47 AM

That EasyFrames mod, is a totally non-secure unit frame addon, which spreading taint all over the place.

tehmoku 01-05-18 10:53 AM

Okay, good to know. Thanks for the replies. The code provided is working excellent.

Usoltsev 03-09-18 02:57 AM

Hello everyone.

Thank you for response about Easy Frames and especially to MunkDev for feedback on the project page.

Version 2.5.0 of Easy Frames is released.

In this version all tainting code was removed.
I think, and I hope that we will never see a "[ADDON_ACTION_BLOCKED] AddOn 'EasyFrames'...." messages in the future.

Resike 03-09-18 06:31 AM

Quote:

Originally Posted by Usoltsev (Post 327148)
Hello everyone.

Thank you for response about Easy Frames and especially to MunkDev for feedback on the project page.

Version 2.5.0 of Easy Frames is released.

In this version all tainting code was removed.
I think, and I hope that we will never see a "[ADDON_ACTION_BLOCKED] AddOn 'EasyFrames'...." messages in the future.

I didn't mean to trash you project, i was just stating facts. You still have 1 leaking global at General.lua:192:mouseover.


All times are GMT -6. The time now is 09:04 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI