WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   'My' ClassPower element seems to crash with '/fstack' (https://www.wowinterface.com/forums/showthread.php?t=56780)

Lyak 10-10-18 12:26 AM

'My' ClassPower element seems to crash with '/fstack'
 
Hi all,

I've not been touching my Class Power element and even '/fstack' for ages.

Just today I've accidentally pressed the hotkey for '/fstack' command and it gave me the following error.

Code:

2x invalid key to 'next'
[C]: in function `SetFrameStack'
...eBlizzard_DebugTools\Blizzard_DebugTools-1.0.lua:673: in function `FrameStackTooltip_Toggle'
FrameXML\ChatFrame.lua:2356: in function `?'
FrameXML\ChatFrame.lua:4734: in function `ChatEdit_ParseText'
FrameXML\ChatFrame.lua:4396: in function `ChatEdit_SendText'
FrameXML\ChatFrame.lua:2884: in function <FrameXML\ChatFrame.lua:2877>
[C]: in function `UseAction'
FrameXML\SecureTemplates.lua:345: in function `handler'
FrameXML\SecureTemplates.lua:623: in function `SecureActionButton_OnClick'
FrameXML\MultiActionBars.lua:24: in function `MultiActionButtonUp'
[string "MULTIACTIONBAR3BUTTON5"]:4: in function <[string "MULTIACTIONBAR3BUTTON5"]:1>

Locals:
(*temporary) = FrameStackTooltip {
 0 = <userdata>
 showRegions = true
 TopOverlay = <unnamed> {
 }
 showHidden = false
 default = 1
 BottomOverlay = <unnamed> {
 }
 showAnchors = true
 nextUpdate = 0
 commandKeys = <table> {
 }
}
(*temporary) = false
(*temporary) = true
(*temporary) = <unnamed> {
 0 = <userdata>
}
(*temporary) = <unnamed> {
 1 = <unnamed> {
 }
 2 = <unnamed> {
 }
 3 = <unnamed> {
 }
 4 = <unnamed> {
 }
 5 = <unnamed> {
 }
 6 = <unnamed> {
 }
 7 = <unnamed> {
 }
 8 = <unnamed> {
 }
 9 = <unnamed> {
 }
 10 = <unnamed> {
 }
 0 = <userdata>
 ClassPowerEnable = <function> defined @!MyEngine\lib\oUF\elements\classpower.lua:234
 ForceUpdate = <function> defined @!MyEngine\lib\oUF\elements\classpower.lua:229
 ClassPowerDisable = <function> defined @!MyEngine\lib\oUF\elements\classpower.lua:247
 isEnabled = true
 __max = 5
 __owner = oUF_CoG {
 }
}
(*temporary) = "5"

So, I've been debugging quite a while and found that it is causing because of my Class Power element code.

Lua Code:
  1. -- Class Power
  2. local classPower = CreateFrame("Frame", nil, UIParent);
  3. classPower:SetWidth(256);
  4. classPower:SetHeight(36);
  5. classPower:SetPoint("CENTER");
  6.  
  7. for i = 1, 10 do
  8.     local bar = CreateFrame("StatusBar", nil, classPower);
  9.     bar:SetSize(36, 36);
  10.  
  11.     if i == 1 then
  12.         bar:SetPoint("LEFT", classPower, "LEFT");
  13.     else
  14.         bar:SetPoint("LEFT", classPower[i - 1], "RIGHT", 3, 0);
  15.     end
  16.  
  17.     classPower[i] = bar;
  18. end
  19.  
  20. self.ClassPower = classPower;

I have also tested with example code provided on class power and it did not cry for such error :(

Could anyone please explain me why and how this error is occurring?

Thank you!

-- Edit #1

Basically this occurs when at least ONE class power bar (one combo point) is visible.

lightspark 10-10-18 06:54 AM

Give names to your bars.

Lua Code:
  1. local classPower = CreateFrame("Frame", nil, UIParent);
  2. classPower:SetWidth(256);
  3. classPower:SetHeight(36);
  4. classPower:SetPoint("CENTER");
  5.  
  6. for i = 1, 10 do
  7.     local bar = CreateFrame("StatusBar", "ClassPowerBar" .. i, classPower);
  8.     bar:SetSize(36, 36);
  9.  
  10.     if i == 1 then
  11.         bar:SetPoint("LEFT", classPower, "LEFT");
  12.     else
  13.         bar:SetPoint("LEFT", classPower[i - 1], "RIGHT", 3, 0);
  14.     end
  15.  
  16.     classPower[i] = bar;
  17. end
  18.  
  19. frame.ClassPower = classPower;

In general, names aren't mandatory, but sometimes, like in this particular case, /fstack is very very picky.

-- edit #1

When you're "nesting" one frame table inside another one like so: frame[1] = anotherFrame, you must give anotherFrame a proper name, it's only needed when you index w/ numbers, if you do something like this: frame["1"] = anotherFrame, you can leave anotherFrame nameless.

Once again, it only applies to "nesting" inside other frames. For example, doing something like this won't cause any issues:
Lua Code:
  1. local classPower = CreateFrame("Frame", nil, UIParent);
  2. classPower:SetWidth(256);
  3. classPower:SetHeight(36);
  4. classPower:SetPoint("CENTER");
  5.  
  6. local container = {};
  7.  
  8. for i = 1, 10 do
  9.     local bar = CreateFrame("StatusBar", nil, classPower);
  10.     bar:SetSize(36, 36);
  11.  
  12.     if i == 1 then
  13.         bar:SetPoint("CENTER");
  14.     else
  15.         bar:SetPoint("LEFT", container[i - 1], "RIGHT", 3, 0);
  16.     end
  17.  
  18.     container[i] = bar;
  19. end
  20.  
  21. frame.ClassPower = container;

Lyak 10-11-18 12:48 AM

Hi lightspark,

First of all, Thank you so much and I really appreciate your help!

I gave each of those elements a name to avoid '/fstack' crying :D

Yeap, it's definitely working :banana:

Lua Code:
  1. -- Class Power
  2. local classPower = CreateFrame("Frame", "$parentClassPower", self);
  3. classPower:SetHeight(setting.height);
  4. classPower:CustomSetPoint(setting.point);
  5.  
  6. for i = 1, 10 do
  7.     local bar = CreateFrame("StatusBar", "$parentBar" .. i, classPower);
  8.     bar:SetStatusBarTexture(LSM:Fetch("statusbar", setting.texture));
  9.     bar:SetWidth(setting.width);
  10.     bar:SetPoint("TOP");
  11.     bar:SetPoint("BOTTOM");
  12.  
  13.     bar:SetTemplate();
  14.     bar:SetBackground();
  15.  
  16.     if i == 1 then
  17.         bar:SetPoint("LEFT");
  18.     else
  19.         bar:SetPoint("LEFT", classPower[i - 1], "RIGHT", 3, 0);
  20.     end
  21.  
  22.     classPower[i] = bar;
  23. end
  24.  
  25. classPower.UpdateColor = ClassPowerUpdateColor;
  26. classPower.PostUpdate = ClassPowerPostUpdate;
  27.  
  28. self.ClassPower = classPower;

So, I do get that it's happening because of nested frames, with numeric as their key instead of string for inner frames, where inner frames do not have their unique name.

But why...?

I had a look at Blizzard_DebugTools-1.0.lua as stated on a error log, but it's totally out of my field :confused:

lightspark 10-11-18 02:58 AM

Quote:

Originally Posted by Lyak (Post 330458)
But why...?

I had a look at Blizzard_DebugTools-1.0.lua as stated on a error log, but it's totally out of my field :confused:

Why do you even care about it? :P

The issue is in the backend, C code, it might be a function that iterates through or does something w/ userdata, which is frame[0], but then it tries to do the same w/ unnamed frames: frame[1], frame[2], etc. It might be something else.

Sitting here and guessing is a waste of time.

Lyak 10-11-18 04:50 AM

Quote:

Originally Posted by lightspark (Post 330459)
Why do you even care about it? :P

The issue is in the backend, C code, it might be a function that iterates through or does something w/ userdata, which is frame[0], but then it tries to do the same w/ unnamed frames: frame[1], frame[2], etc. It might be something else.

Sitting here and guessing is a waste of time.

Aight!

Time to proceed forward then :banana:


All times are GMT -6. The time now is 09:11 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI