Thread: Stack overflow
View Single Post
01-09-24, 05:35 PM   #1
Benalish
A Flamescale Wyrmkin
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 123
Stack overflow

May I ask why this code goes into stack overflow

Lua Code:
  1. local function SetWidgetScript(frame,method)
  2.     if frame:IsShown() then
  3.         for i = 1, #frame.buttons do
  4.             frame.buttons[i]:HookScript("OnMouseDown", method)
  5.         end
  6.     else
  7.         frame:SetScript(
  8.             "OnShow", --when "OnShow" is fired, IsShown() become true
  9.                 SetWidgetScript(frame,method)
  10.         )
  11.     end
  12. end

While it works fine by simply wrapping myfunc() inside the function environment after "OnShow"?

Lua Code:
  1. local function SetWidgetScript(frame,method)
  2.     if frame:IsShown() then
  3.         for i = 1, #frame.buttons do
  4.             frame.buttons[i]:HookScript("OnMouseDown", method)
  5.         end
  6.     else
  7.         frame:SetScript(
  8.             "OnShow", --when "OnShow" is fired, IsShown() become true
  9.             function()
  10.                 SetWidgetScript(frame,method)
  11.             end
  12.         )
  13.     end
  14. end

Last edited by Benalish : 01-09-24 at 05:42 PM.
  Reply With Quote