View Single Post
07-19-16, 12:03 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
You can also copy functions from the old metatable to the new one. This will impose a longer setup time and use up more memory, but will save CPU usage during runtime. Taint is also a problem if the frame is protected, but it's unclear whether the replacement of the frame's metatable would cause taint by itself anyway.

Lua Code:
  1. local frame=CreateFrame("Frame")
  2. local meta={__index={}};
  3.  
  4. -- Define functions after these lines
  5. for name,func in pairs(getmetatable(frame).__index) do meta.__index[name]=func; end
  6. setmetatable(frame,meta);
  7.  
  8. function meta.__index:foo()
  9.     print("bar");
  10. end
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 07-19-16 at 12:07 PM.
  Reply With Quote