View Single Post
11-03-22, 09:26 AM   #15
Deadlyz
A Wyrmkin Dreamwalker
 
Deadlyz's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 55
Originally Posted by SDPhantom View Post
You need to set this hook outside or it'll keep hooking itself indefinitely. Eventually, this will cause a stack overflow when the hook is called.



This is the alternative I came up with. It only applies the position hook once.
Lua Code:
  1. --  Doesn't need to be done, but saves some (not all) processing
  2. TargetFrame:UnregisterEvent("UNIT_AURA");
  3. FocusFrame:UnregisterEvent("UNIT_AURA");
  4.  
  5. local function ReleaseAllAuras(self)
  6.     for obj in self.auraPools:EnumerateActive() do obj:Hide(); end
  7.     self.auraPools:ReleaseAll()--   Cleanup
  8. end
  9.  
  10. hooksecurefunc(TargetFrame,"UpdateAuras",ReleaseAllAuras);
  11. hooksecurefunc(FocusFrame,"UpdateAuras",ReleaseAllAuras);
  12.  
  13. local function SpellBar_SetPoint(self)
  14.     local meta=getmetatable(self).__index;--    Calls through self will trigger our hook, so we're making them through the metatable
  15.     meta.ClearAllPoints(self);
  16.     meta.SetPoint(self,"TOPLEFT",meta.GetParent(self),"BOTTOMLEFT",43,-28);
  17. end
  18.  
  19. hooksecurefunc(TargetFrame.spellbar,"SetPoint",SpellBar_SetPoint);
  20. hooksecurefunc(FocusFrame.spellbar,"SetPoint",SpellBar_SetPoint);
Thanks a lot! I'm going to update my file with your code
__________________

My last movie: Rogue Sweethearts
  Reply With Quote