Quantcast
WoWInterface - View Single Post - [ADDON_ACTION_BLOCKED] tried to call the protected function "<unnamed>:SetHeight()".
View Single Post
11-04-18, 09:45 PM   #1
Lyak
A Cyclonian
Join Date: Jul 2018
Posts: 46
[ADDON_ACTION_BLOCKED] tried to call the protected function "<unnamed>:SetHeight()".

Hi all,

I am currently making an addon that displays all the enemies' unitframe by reproducing nameplates based on NAME_PLATE_CREATED, NAME_PLATE_UNIT_ADDED, NAME_PLATE_UNIT_REMOVED events.

Lua Code:
  1. function AddOn:NAME_PLATE_CREATED(...)
  2.     local setting = AddOn.db.global;
  3.  
  4.     -- Create nameplate
  5.     local nameplate = CreateFrame("Frame", nil, self);
  6.     nameplate:SetSize(setting.width, setting.iconSize);
  7.    
  8.     -- Position each nameplates
  9.     local listLength = #self.nameplateList;
  10.     if (listLength == 0) then
  11.         nameplate:SetPoint("TOP");
  12.     else
  13.         nameplate:SetPoint("TOP", self.nameplateList[listLength], "BOTTOM", 0, -3);
  14.     end
  15.  
  16.     self.nameplateList[listLength + 1] = nameplate;
  17.    
  18.     local health = CreateFrame("StatusBar", nil, nameplate);
  19.     health:SetStatusBarTexture(LSM:Fetch("statusbar", setting.texture));
  20.     health:SetMinMaxValues(0, 1);
  21.     health:SetAllPoints(nameplate);
  22.    
  23.     nameplate.health = health;
  24.  
  25.     -- Adjust the height on nameplate creation
  26.     if (listLength == 1) then
  27.         self:SetHeight(setting.iconSize);
  28.     elseif (listLength > 1) then
  29.         self:SetHeight(self:GetHeight() + 3 + setting.iconSize);
  30.     end
  31. end
  32.  
  33. function InitializeHandler()
  34.     local setting = AddOn.db.global;
  35.  
  36.     local handler = CreateFrame("Frame", nil, UIParent, "SecureHandlerStateTemplate");
  37.     handler:SetWidth(setting.width);
  38.     handler:CustomSetPoint(setting.point);
  39.  
  40.     RegisterStateDriver(handler, "visibility", "[petbattle] hide; show");
  41.    
  42.     AddOn.handler = handler;
  43.  
  44.     handler.nameplateList = {};
  45. end

I am aware of that this taint is occurring because the new nameplates are being created and the height is set while in the combat.

+ The reason that I am using SecureHandlerStateTemplate is to hide such frame while in a pet battle (as it is shown in L#40).

Is there any possible solution to prevent such taint occurring? Or should I only use my handler only to hide/show the frame in/out of pet battle, and create another frame on top of it which manages visual part?

Thank you!
  Reply With Quote