WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   secure actionbutton taints again :( (https://www.wowinterface.com/forums/showthread.php?t=43374)

Rilgamon 04-30-12 11:11 AM

secure actionbutton taints again :(
 
Lua Code:
  1. local _,class = UnitClass('player')
  2. local xoffset, yoffset = 8,0
  3.  
  4. local function createBar(bid,id)
  5.     local f = CreateFrame("Frame", "zzABar"..bid, UIParent, "SecureHandlerStateTemplate",id)
  6.     f:SetWidth(1)
  7.     f:SetHeight(1)
  8.     f:SetPoint("CENTER")
  9.     f:SetAttribute('_onstate-page', [[
  10.         print(newstate)
  11.         self:SetAttribute('actionpage', newstate)
  12.         control:ChildUpdate('actionpage', newstate)
  13.     ]])
  14.     if(class == "WARRIOR") then
  15.         print("war")
  16.         RegisterStateDriver(f, "page", "[bonusbar:1] 7;[bonusbar:2] 8;[bonusbar:3] 9;1")
  17.     end
  18.    
  19.     local lastbutton = f
  20.     for i = 1, 12 do
  21.         local b = CreateFrame("CheckButton", "$PARENTActionButton"..i, f, "SecureActionButtonTemplate ActionButtonTemplate",i)
  22.         b:SetWidth(32)
  23.         b:SetHeight(32)
  24.         b:SetPoint("TOPLEFT", lastbutton, "TOPRIGHT", xoffset, yoffset)
  25.         lastbutton = b
  26.         ActionButton_OnLoad(b)
  27.         b:SetAttribute('action--base',i)
  28.         b:SetAttribute('showgrid', 1)
  29.         b:SetAttribute('_childupdate-actionpage', [[
  30.             local offset = (message -1) * 12 + self:GetAttribute('action--base')
  31.             self:SetAttribute('action', self:GetAttribute('action--base'))
  32.             print(message, offset, self:GetAttribute('action--base'))
  33.         ]])
  34.         b:SetScript("OnAttributeChanged",ActionButton_UpdateAction)
  35.         b:SetAttribute('action', i)
  36.  
  37.     end
  38. end

I try to have a bar that switches automaticly. The code above works but I get taints over and over.

Code:

4/30 18:55:05.677  An action was blocked in combat because of taint from zz_Actionbuttons - zzABar1ActionButton1:Show()
4/30 18:55:05.677      Interface\FrameXML\ActionButton.lua:246 ActionButton_Update()
4/30 18:55:05.677      Interface\FrameXML\ActionButton.lua:484 ActionButton_OnEvent()
4/30 18:55:05.677      Interface\FrameXML\ActionButton.lua:105

But I have no clue what I should do to make my code secure.
Someone got an easy example how this works ? Looked at BT and Dominos but thats a little above my skills ;)

SDPhantom 04-30-12 12:42 PM

The taint is generated because calls to frame:Show() or frame:Hide() are blocked if used on a protected frame while in combat. There is a way around this using SecureStateDrivers, but this is for very specific reasons.

This might be caused by either of the links to Blizzards functions you have. ActionButton_OnLoad() or ActionButton_UpdateAction(). From the taint path, it looks to be the first.



Something you might try is use XML to create a template and use the following in between the <Scripts> tags:
Code:

<OnLoad function="ActionButton_OnLoad"/>
Then reference the template in your CreateFrame() call and set up the rest.

I'm not entirely sure if taint would be passed on to the OnLoad script, but it's worth a try.

Rilgamon 04-30-12 03:29 PM

I create from CheckButtonTemplate (ActionBarFrame.xml)... not sure why, but my code only works if
I use the two (same for OnAttributeChanged) again event though the template has both defined.

Lua Code:
  1. <CheckButton name="ActionBarButtonCodeTemplate" inherits="SecureActionButtonTemplate" virtual="true">
  2.         <Scripts>
  3.             <OnLoad>
  4.                 ActionButton_OnLoad(self);
  5.             </OnLoad>
  6.             <OnAttributeChanged>
  7.                 ActionButton_UpdateAction(self, name, value);
  8.             </OnAttributeChanged>
  9.             <OnEvent>
  10.                 ActionButton_OnEvent(self, event, ...);
  11.             </OnEvent>

Rilgamon 04-30-12 03:36 PM

grml ... posting it helps :)

I forgot to use ActionBarButtonCodeTemplate for the CheckButton inherit.
Thank you helping me looking at it from a different view :D


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

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