I have this interesting bug that I need to fix. I've couple of solutions ready but before I implement one of them I like to ask why such an error may happen. The reason I am asking is because I can't replicate this bug so I am kind of implementing a fail recovery solution.
The error I get is on a TList object: "[EListError] List index out of bounds (0)".
The TList contains few TForm objects where we made them invisible then add them to the TList right after that action. Now we want to make them visible again and free and nil the TList after that. Error happens when we want to make the forms visible again.
So there's a loop and the TList.Count has a value. The code gets into loop and the above error happens. Isn't above error implies that there's no item at the specific index but the list count is greater than zero, how could this be?
The only out of ordinary thing here might be the for loop counting down so that we display the forms in reverse order.
for ii := FormListObject.Count - 1 downto 0 do begin
// Error happens here
TForm(FormListObject[ii]).Show;
end;
Do you think this is a gui threading issue, a child item issue or somehow one of the forms got destroyed/killed and the list has a dead reference? Still I thought this error meant that there's no TList item at index 0, dead reference should trigger an access violation error, no?
OnShowevent that modifies the list? - whosrdaddy