[Bug]Crash When Iterating Over Global Table
Posted: Thu Jan 30, 2020 5:28 pm
Occasionally, when I try to iterate through a global table (which was declared in Globals), I get an error: bad arguement #1 to 'for iterator' (table expected, got nil);
Now, I know for a fact that this table is not nil, it is set once and never changes. But, sometimes, the program runs fine and other times it gives this error. On the times when it gives the error, I click the bebug error (presumably to open the section where the error occured) and SDStudio crashes.
It seems to happen more often if I have edited Globals recently.
EDIT: Okay, I've narrowed down a little further,
I've got a combo box called cmb_classes. The combobox is set to autosort.
In the OnCreate event of my window I have this code.
Now, sometimes when I start my program, the combobox is autosorted and sometimes it is not (this is unexpected behaviour). Whether or not it is autosorted is totally random. Whenever it does get sorted, I get the error and the subsequent crash. Whenever it does not get sorted, everything works fine.
Now, I know for a fact that this table is not nil, it is set once and never changes. But, sometimes, the program runs fine and other times it gives this error. On the times when it gives the error, I click the bebug error (presumably to open the section where the error occured) and SDStudio crashes.
It seems to happen more often if I have edited Globals recently.
EDIT: Okay, I've narrowed down a little further,
I've got a combo box called cmb_classes. The combobox is set to autosort.
In the OnCreate event of my window I have this code.
Code: Select all
ComboBox:DeleteAllItems(cmb_classes);
ComboBox:DeleteAllItems(cmb_types);
for sClass, tTypes in pairs(_tClassAndTypes) do
ComboBox:AddItem(cmb_classes, sClass, "");
end