Access violation exception from Delphi's Supports -> QueryInterface

Posted by Sharon on Stack Overflow See other posts from Stack Overflow or by Sharon
Published on 2010-03-21T10:10:18Z Indexed on 2010/03/21 10:11 UTC
Read the original article Hit count: 305

Hi,

I have the following piece of code:

for i := 0 to FControlList.Count - 1 do

  if Supports(IMyControl(FControlList[i]), IMyControlEx) then
  begin
    MyControlEx := IMyControl(FControlList[i]) as IMyControlEx;
    MyControlEx.DoYourMagic(Self, SomeData);
  end;

This code is called many times during my application execution, but in some specific cases it fails inside the Supports() method. And more specifically - it seems to fall inside the QueryInterface() call within the Supports() method.

I checked that FControlList is not nil and FControlList[i] is not nil and it still happens.

Any idea will be appreciated!!!

© Stack Overflow or respective owner

Related posts about access-violation

Related posts about delphi