Strange EListError occurance (when accessing variable-defined index)
Posted
by michal
on Stack Overflow
See other posts from Stack Overflow
or by michal
Published on 2009-12-27T12:35:36Z
Indexed on
2010/06/02
22:54 UTC
Read the original article
Hit count: 340
Hi, I have a TList which stores some objects. Now I have a function which does some operations on that list:
function SomeFunct(const AIndex: integer): IInterface
begin
if (AIndex > -1) and (AIndex < fMgr.Windows.Count ) then
begin
if (fMgr.Windows[AIndex] <> nil) then
begin
if not Supports(TForm(fMgr.Windows[AIndex]), IMyFormInterface, result) then
result:= nil;
end;
end
else
result:= nil;
end;
now, what is really strange is that accessing fMgr.Windows with any proper index causes EListError... However if i hard-code it (in example, replace AIndex with value 0 or 1) it works fine. I tried debugging it, the function gets called twice, with arguments 0 and 1 (as supposed).
while AIndex = 0, evaluating fMgr.Windows[AIndex] results in EListError at $someAddress, while evaluating fMgr.Windws[0] instead - returns proper results ...
what is even more strange, even though there is an EListError, the function returns proper data ... and doesn't show anything. Just info on two EListError memory leaks on shutdown (using FastMM)
any ideas what could be wrong?!
Thanks in advance michal
© Stack Overflow or respective owner