Thread Tools Display Modes
03-11-14, 11:06 AM   #1
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Error the first time i cast a spell.

Evertime just after login I get tis error when I cast a spell, weather its to hearth or mount or any thing else as long as it is a castable spell it throws this error.

But if I press close the next time I cast it shows no error.

Here is the error:
Code:
Message: C stack overflow
Time: 03/11/14 09:49:33
Count: 1
Stack: [C]: in function `SetWidth'
Interface\AddOns\BasicUI\Modules\General\Castbar.lua:29: in function <Interface\AddOns\BasicUI\Modules\General\Castbar.lua:17>
Interface\AddOns\BasicUI\Modules\General\Castbar.lua:107: in function <Interface\AddOns\BasicUI\Modules\General\Castbar.lua:105>
[C]: in function `SetWidth'
Interface\AddOns\BasicUI\Modules\General\Castbar.lua:29: in function <Interface\AddOns\BasicUI\Modules\General\Castbar.lua:17>
Interface\AddOns\BasicUI\Modules\General\Castbar.lua:107: in function <Interface\AddOns\BasicUI\Modules\General\Castbar.lua:105>
[C]: in function `SetWidth'
Interface\AddOns\BasicUI\Modules\General\Castbar.lua:29: in function <Interface\AddOns\BasicUI\Modules\General\Castbar.lua:17>
Interface\AddOns\BasicUI\Modules\General\Castbar.lua:107: in function <Interface\AddOns\BasicUI\Modules\General\Castbar.lua:105>
[C]: in function `SetWidth'
Interface\AddOns\BasicUI\Modules\General\Castbar.lua:29: in function <Interface\AddOns\BasicUI\Modules\General\Castbar.lua:17>
Interface\AddOns\BasicUI\Modules\General\Castbar.lua:107: in function <Interface\AddOns\BasicUI\Modules\General\Castbar.lua:105>
...
[C]: in function `SetWidth'
Interface\AddOns\BasicUI\Modules\General\Castbar.lua:29: in function <Interface\AddOns\BasicUI\Modules\General\Castbar.lua:17>
Interface\AddOns\BasicUI\Modules\General\Castbar.lua:107: in function <Interface\AddOns\BasicUI\Modules\General\Castbar.lua:105>
[C]: in function `SetWidth'
Interface\AddOns\BasicUI\Modules\General\Castbar.lua:29: in function <Interface\AddOns\BasicUI\Modules\General\Castbar.lua:17>
Interface\AddOns\BasicUI\Modules\General\Castbar.lua:107: in function <Interface\AddOns\BasicUI\Modules\General\Castbar.lua:105>
[C]: in function `SetValue'
Interface\FrameXML\CastingBarFrame.lua:279: in function <Interface\FrameXML\CastingBarFrame.lua:268>
[C]: in function `CastingBarFrame_OnUpdate'
[string "*:OnUpdate"]:1: in function <[string "*:OnUpdate"]:1>

Locals: (*temporary) = CastingBarFrame {
 0 = <userdata>
 showTradeSkills = true
 holdTime = 0
 d = <table> {
 }
 border = CastingBarFrameBorder {
 }
 unit = "player"
 df = CastbarCastingBarFrame {
 }
 showCastbar = true
 value = 0.016000000759959
 l = true
 icon = CastingBarFrameIcon {
 }
 barSpark = CastingBarFrameSpark {
 }
 timer = <unnamed> {
 }
 castID = 52
 barFlash = CastingBarFrameFlash {
 }
 maxValue = 1.5
 text = CastingBarFrameText {
 }
 name = <unnamed> {
 }
 lag = <unnamed> {
 }
 Show = <function> defined =[C]:-1
 borderShield = CastingBarFrameBorderShield {
 }
 flash = 1
 showShield = false
 casting = 1
 update = 0.1
 reset = true
}
(*temporary) = 240
(*temporary) = 0.016000000759959
(*temporary) = <function> defined =[C]:-1
(*temporary) = <function> defined @Interface\AddOns\BasicUI\Modules\General\Castbar.lua:105
(*temporary) = CastingBarFrame {
 0 = <userdata>
 showTradeSkills = true
 holdTime = 0
 d = <table> {
 }
 border = CastingBarFrameBorder {
 }
 unit = "player"
 df = CastbarCastingBarFrame {
 }
 showCastbar = true
 value = 0.016000000759959
 l = true
 icon = CastingBarFrameIcon {
 }
 barSpark = CastingBarFrameSpark {
 }
 timer = <unnamed> {
 }
 castID = 52
 barFlash = CastingBarFrameFlash {
 }
 maxValue = 1.5
 text = CastingBarFrameText {
 }
 name = <unnamed> {
 }
 lag = <unnamed> {
 }
 Show = <function> defined =[C]:-1
 borderShield = CastingBarFrameBorderShield {
 }
 flash = 1
 showShield = false
 casting = 1
 update = 0.1
 reset = true
}
(*temporary) = 0.016000000759959
Here is my castbar.lua
Lua Code:
  1. local B, C, DB = unpack(select(2, ...)) -- Import:  B - function; C - config; DB - Database
  2.  
  3. if C['castbar'].enable ~= true then return end
  4.  
  5. --[[
  6.  
  7.     All Credit for Castbar.lua goes to thek.
  8.     thek: Castbar = [url]http://www.wowinterface.com/downloads/info11334-thekCastbar.html[/url].
  9.     Edited by Cokedriver.
  10.    
  11. ]]
  12.  
  13. local d = {};
  14. local find = string.find;
  15. local floor = math.floor;
  16.  
  17. local function Set(a, k)
  18.     a:SetFrameLevel(_G[k]:GetFrameLevel() - 1);
  19.     if find(k, "MirrorTimer") then
  20.         _G[k.."StatusBar"]:SetStatusBarColor(B.ccolor.r, B.ccolor.g, B.ccolor.b);
  21.         _G[k.."StatusBar"]:SetWidth(240);
  22.         _G[k.."StatusBar"]:SetHeight(24);
  23.         _G[k]:ClearAllPoints();
  24.         _G[k]:SetPoint("TOPLEFT", a, "TOPLEFT", B.scale(_G[k].d.x), -B.scale(_G[k].d.y));
  25.         _G[k.."StatusBar"]:ClearAllPoints();
  26.         _G[k.."StatusBar"]:SetPoint("TOPLEFT", a, "TOPLEFT", B.scale(5), -B.scale(_G[k].d.y));
  27.     else
  28.         _G[k]:SetStatusBarColor(B.ccolor.r, B.ccolor.g, B.ccolor.b);
  29.         _G[k]:SetWidth(240);
  30.         _G[k]:SetHeight(24);
  31.         _G[k]:ClearAllPoints();
  32.         _G[k]:SetPoint("TOPLEFT", a, "TOPLEFT", B.scale(_G[k].d.x), -B.scale(_G[k].d.y))
  33.     end;
  34.     if C['castbar'][k].enableLag then
  35.         local d, u, l = GetNetStats();
  36.         local min, max = _G[k]:GetMinMaxValues();
  37.         local lv = ( l / 1000 ) / ( max - min );
  38.         if ( lv < 0 ) then lv = 0; elseif ( lv > 1 ) then lv = 1 end;
  39.         if ( _G[k].channeling ) then
  40.             _G[k].lag:ClearAllPoints();
  41.             _G[k].lag:SetPoint("LEFT", _G[k], "LEFT", 0, 0);
  42.         else
  43.             _G[k].lag:ClearAllPoints();
  44.             _G[k].lag:SetPoint("RIGHT", _G[k], "RIGHT", 0, 0);
  45.         end;
  46.         _G[k].lag:SetWidth(_G[k]:GetWidth() * lv);
  47.     end
  48. end;
  49.  
  50. if C['castbar']["TargetFrameSpellBar"].enable then
  51.     function Target_Spellbar_AdjustPosition()
  52.         Set(_G["TargetFrameSpellBar"].df, "TargetFrameSpellBar");
  53.     end;
  54. end;
  55. if C['castbar']["FocusFrameSpellBar"].enable then
  56.     function Focus_Spellbar_AdjustPosition()
  57.         Set(_G["FocusFrameSpellBar"].df, "FocusFrameSpellBar");
  58.     end;
  59. end
  60.  
  61. for k, _ in pairs(C['castbar']) do
  62.     if (k ~="enable" and C['castbar'][k].enable) then
  63.         local a = CreateFrame("Frame", "Castbar"..k, UIParent);
  64.         d.w, d.h, d.x, d.y = nil, nil, nil, nil;
  65.  
  66.         _G[k.."Border"]:SetTexture("");
  67.         _G[k.."Text"]:ClearAllPoints("");
  68.         _G[k.."Text"]:SetFont(C['media'].fontNormal, C["castbar"][k].fontSize, "");
  69.  
  70.         if find(k, "MirrorTimer") then
  71.             d.w = 240 + (5 * 2);
  72.             d.h = 24 + (5 * 2);
  73.             d.x = 5;
  74.             d.y = 5;
  75.            
  76.             _G[k.."Text"]:SetPoint("CENTER", k, -10, 2);
  77.             _G[k.."StatusBar"]:SetStatusBarTexture(C['castbar'].statusbar);
  78.         else
  79.             d.w = 240 + 24 + (5 * 2) + 5;
  80.             d.h = 24 + (5 * 2);
  81.             d.x = 24 + 5 + 5;
  82.             d.y = 5;
  83.            
  84.             _G[k.."Text"]:SetPoint(C['castbar'][k].textPosition);
  85.             _G[k]:SetStatusBarTexture(C['castbar'].statusbar);
  86.             _G[k.."Flash"].Show = _G[k.."Flash"].Hide;
  87.             _G[k.."Spark"].Show = _G[k.."Spark"].Hide;
  88.            
  89.             if _G[k.."BorderShield"] then
  90.                 _G[k.."BorderShield"].Show = _G[k.."BorderShield"].Hide;
  91.             end;
  92.            
  93.             if _G[k.."Icon"] then
  94.                 _G[k.."Icon"]:Show();
  95.                 _G[k.."Icon"]:ClearAllPoints();
  96.                 _G[k.."Icon"]:SetPoint("LEFT", _G[k], -27, 0);
  97.                 _G[k.."Icon"]:SetWidth(23);
  98.                 _G[k.."Icon"]:SetHeight(23);
  99.                 _G[k.."Icon"]:SetTexCoord(.08, .92, .08, .92);
  100.             end;
  101.            
  102.             _G[k]:HookScript("OnSizeChanged", function()
  103.                 _G[k].reset = true;
  104.             end);
  105.             _G[k]:HookScript("OnValueChanged", function()
  106.                 if _G[k].reset then
  107.                     Set(a, k);
  108.                     _G[k].reset = false;
  109.                 end;
  110.             end);
  111.            
  112.             if C['castbar'][k].enableLag then
  113.                 _G[k].lag = _G[k]:CreateTexture(nil, "BACKGROUND")
  114.                 _G[k].lag:SetHeight(24)
  115.                 _G[k].lag:SetWidth(0)
  116.                 _G[k].lag:SetPoint("RIGHT", _G[k], "RIGHT", 0, 0)
  117.                 _G[k].lag:SetTexture(1, 0, 0, 1)
  118.             end;
  119.         end;    
  120.              
  121.         if C['castbar'][k].enableTimer then
  122.             _G[k].timer = _G[k]:CreateFontString(nil);
  123.             _G[k].timer:SetFont(C['media'].fontNormal, C['media'].fontSize, "");
  124.             _G[k].timer:SetPoint("RIGHT", _G[k], "RIGHT", -5, 0);
  125.             _G[k].update = .1;
  126.         end;
  127.        
  128.         a:SetPoint(C['castbar'][k].relAnchor,"UIParent",C['castbar'][k].selfAnchor, B.scale(C['castbar'][k].offSetX),B.scale(C['castbar'][k].offSetY))
  129.            
  130.         a:SetWidth(d.w); a:SetHeight(d.h);
  131.         a:SetBackdropColor(.1, .1, .1, .95);
  132.         a:SetBackdrop({
  133.             bgFile = C['castbar'].background,
  134.             edgeFile = C['castbar'].border,
  135.             tile = true, tileSize = 16, edgeSize = 15,
  136.             insets = {left = 3, right = 3, top = 3, bottom = 3}
  137.         })
  138.         if C['general'].classcolor ~= true then
  139.             a:SetBackdropBorderColor(C['general'].color.r,C['general'].color.g,C['general'].color.b)
  140.         else
  141.             a:SetBackdropBorderColor(B.ccolor.r, B.ccolor.g, B.ccolor.b)
  142.         end
  143.         a:SetParent(_G[k]);
  144.         a:SetMovable(true);
  145.         a:EnableMouse(false);
  146.         a:RegisterForDrag("LeftButton");
  147.         a:SetScript("OnDragStart", function(self) self:StartMoving() end);
  148.         a:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end);
  149.         a.name = a:CreateFontString(nil, "OVERLAY");
  150.         a.name:SetFont(C['media'].fontNormal, C['media'].fontSize, "");
  151.         a.name:SetPoint("CENTER", a);
  152.         _G[k].d = d; _G[k].df = a; _G[k].name = a.name; _G[k].l = true;
  153.        
  154.         hooksecurefunc(_G[k], "Show", function() Set(a, k) end);
  155.     end;
  156. end;
  157.  
  158. hooksecurefunc("CastingBarFrame_OnUpdate", function(self, elapsed)
  159.     if not self.timer then return end
  160.     if self.update and self.update < elapsed then
  161.         if self.casting then
  162.             self.timer:SetText(format("(%.1f)", max(self.maxValue - self.value, 0)))
  163.         elseif self.channeling then
  164.             self.timer:SetText(format("(%.1f)", max(self.value, 0)))
  165.         else
  166.             self.timer:SetText("")
  167.         end
  168.         self.update = .1
  169.     else
  170.         self.update = self.update - elapsed
  171.     end
  172. end)
  173. UIPARENT_MANAGED_FRAME_POSITIONS["CastingBarFrame"] = nil;

Here is my options for the castbar:
Lua Code:
  1. ------------------
  2. --Castbar Options
  3. ------------------
  4. DB["castbar"] = {  
  5.     ["enable"] = true,
  6.     ["border"] = "Blizzard Tooltip",
  7.     ["background"] = "Blizzard Dialog Background Dark",
  8.     ["statusbar"] = "Blizzard",
  9.    
  10.  
  11.     ["CastingBarFrame"] = {
  12.         ["enable"] = true,
  13.         ["fontSize"] = 18,
  14.         ["textPosition"] = "CENTER",
  15.         ["enableLag"] = true,
  16.         ["enableTimer"] = true,
  17.         ["selfAnchor"] = "BOTTOM",
  18.         ["relAnchor"] = "BOTTOM",
  19.         ["offSetX"] = 0,
  20.         ["offSetY"] = 175,
  21.     },
  22.     ["TargetFrameSpellBar"] = {
  23.         ["enable"] = false,
  24.         ["fontSize"] = 18,
  25.         ["textPosition"] = "CENTER",
  26.         ["enableLag"] = true,
  27.         ["enableTimer"] = true,
  28.         ["selfAnchor"] = "TOP",
  29.         ["relAnchor"] = "TOP",
  30.         ["offSetX"] = 0,
  31.         ["offSetY"] = -250,
  32.     },
  33.     ["FocusFrameSpellBar"] = {
  34.         ["enable"] = true,
  35.         ["fontSize"] = 18,
  36.         ["textPosition"] = "CENTER",
  37.         ["enableLag"] = true,
  38.         ["enableTimer"] = true,
  39.         ["selfAnchor"] = "TOP",
  40.         ["relAnchor"] = "TOP",
  41.         ["offSetX"] = 0,
  42.         ["offSetY"] = -165,
  43.     },
  44.     ["MirrorTimer1"] = {
  45.         ["enable"] = true,
  46.         ["fontSize"] = 18,
  47.         ["enableTimer"] = true,
  48.         ["selfAnchor"] = "TOP",
  49.         ["relAnchor"] = "TOP",
  50.         ["offSetX"] = 0,
  51.         ["offSetY"] = -75,
  52.     },
  53.     ["PetCastingBarFrame"] = {
  54.         ["enable"] = true,
  55.         ["fontSize"] = 18,
  56.         ["textPosition"] = "CENTER",
  57.         ["enableTimer"] = true,
  58.         ["selfAnchor"] = "BOTTOM",
  59.         ["relAnchor"] = "BOTTOM",
  60.         ["offSetX"] = 0,
  61.         ["offSetY"] = 200,
  62.     },
  63. }

And finally here is the config I use to switch from DB to C:
Lua Code:
  1. ----------------------------------------------------------------------------
  2. -- This Module loads new user settings if BasicUI_Config is loaded
  3. ----------------------------------------------------------------------------
  4. local B, C, DB = unpack(select(2, ...)) -- Import:  B - function; C - config; DB - Database
  5.  
  6. --Convert default database
  7. for group,options in pairs(DB) do
  8.     if not C[group] then C[group] = {} end
  9.     for option, value in pairs(options) do
  10.         C[group][option] = value
  11.     end
  12. end
  13.  
  14. if IsAddOnLoaded("BasicUI_Config") then
  15.     local BasicUIConfig = LibStub("AceAddon-3.0"):GetAddon("BasicUIConfig")
  16.     BasicUIConfig:Load()
  17.  
  18.     --Load settings from BasicUIConfig database
  19.     for group, options in pairs(BasicUIConfig.db.profile) do
  20.         if C[group] then
  21.             for option, value in pairs(options) do
  22.                 C[group][option] = value
  23.             end
  24.         end
  25.     end
  26.        
  27.     B.SavePath = BasicUIConfig.db.profile
  28. end

I'm not to sure as to why the "Set" function seems to be throwing a error.

Any help would be great.

Thanks
Coke
  Reply With Quote
03-11-14, 11:47 AM   #2
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
Try changing:
Code:
            _G[k]:HookScript("OnValueChanged", function()
                if _G[k].reset then
                    Set(a, k);
                    _G[k].reset = false;
                end;
            end);
to:
Code:
            _G[k]:HookScript("OnValueChanged", function(self)
                if self.reset and not self.reseting then
                    self.reseting = true
                    Set(a, k)
                    self.reseting = nil
                    self.reset = nil
                end
            end)
  Reply With Quote
03-11-14, 11:56 AM   #3
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
My first guess would be this part:

Lua Code:
  1. 102.            _G[k]:HookScript("OnSizeChanged", function()
  2. 103.                _G[k].reset = true;
  3. 104.            end);
  4.  
  5. 105.            _G[k]:HookScript("OnValueChanged", function()
  6. 106.                if _G[k].reset then
  7. 107.                    Set(a, k);
  8. 108.                    _G[k].reset = false;
  9. 109.                end;
  10. 110.            end);
You're running into an infinite loop. You are calling Set() on OnSizeChanged ,and within Set() you do things like _G[k.."StatusBar"]:SetWidth(240); ... which fires OnSizeChanged, which is calling Set() ... aso.

As far as I can remember at some point the game engine does stop those infinite loops and ignores the code then. That's why the error is only thrown once.

I'm absolutly not sure if this is the problem or if my description is correct. But it could be a point to start investigating.
  Reply With Quote
03-11-14, 06:01 PM   #4
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Vrul View Post
Try changing:
Code:
            _G[k]:HookScript("OnValueChanged", function()
                if _G[k].reset then
                    Set(a, k);
                    _G[k].reset = false;
                end;
            end);
to:
Code:
            _G[k]:HookScript("OnValueChanged", function(self)
                if self.reset and not self.reseting then
                    self.reseting = true
                    Set(a, k)
                    self.reseting = nil
                    self.reset = nil
                end
            end)
This worked perfectly no more errors.

Also I am following Phanx's advice and now have installed Bugsack to help me and others when errors occur.

Thanks
Coke
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Error the first time i cast a spell.


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