Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 

WoWInterface » Developer Discussions » Lua/XML Help » Stack overflow


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off