My form is implementing some interface. Since TForm is derived from TComponent which implements IInterface without reference counting I'm creating my form with an owner which will take care of freeing the memory. But when it's doing it - it generates an AV.

My form is implementing some interface. Since TForm is derived from TComponent which implements IInterface without reference counting I'm creating my form with an owner which will take care of freeing the memory. But when it's doing it - it generates an AV.

example

  ISomeinterface = Interface
  ['{04D066E2-8EE1-4344-883A-177AEC2A38E4}']
(...)
  end;

  TFInterfacedForm = class(TForm, ISomeInterface)
(...)
  end;

var
  SomeInterface: ISomeinterface;

initialization
  SomeInterface := TFInterfacedForm.Create(Application) as ISomeinterface;

It generates AV on application closing. I'm using Delphi 7

Comments

  1. Try:

    Assert(GetInterface(ISomeInterface, SomeInterface));

    ReplyDelete
  2. Stefan Meisner Jackpot! Nicholas Ring Yes, it helps :)

    ReplyDelete
  3. Oops! I was wrong. Thanks to Stefan Meisner

    ReplyDelete

Post a Comment