RE: Component and Interface
"Shkolnik M." <[email protected]>
| Newsgroups | gmane.comp.lang.delphi.programming |
|---|---|
| Message-ID | <[email protected]> |
When you close your app, you must "release" your interface: Msg := nil; With best regards, Mike Shkolnik EMail: [email protected] http://www.scalabium.com -----Original Message----- From: Markus Ostenried [mailto:[email protected]] Sent: Friday, July 11, 2003 4:10 PM To: [email protected] Subject: [Delphi] Component and Interface Hi all, I have a component implementing an interface but its destructor never gets called. My interface is declared in a seperate unit: type IMsgComp = interface( IUnknown ) ... end; In a DLL I have a component implementing the interface: type TMsgComp = class( TComponent, IMsgComp ); ... end; The DLL exports this function: function CreateMsgComp: IMsgComp; begin Result := TMsgComp.Create( nil ); end; I'm using it in another DLL like this: procedure TForm1.MyMethod; var Msg: IMsgComp; begin Msg := CreateMsgComp; // do some stuff end; Both the DLL and the EXE use the same unit in which the interface is declared. The problem is that TMsgComp's destructor isn't called - even if I free the TForm1 instance. Thus the contained Objects inside TMsgComp don't get freed. This is strange because when using TInterfacedObject instead of TComponent to implement an interface the Objects destructor gets called when the interface variable isn't used anymore. Can somebody please help me ? TIA, Markus ------------------------ Yahoo! Groups Sponsor ---------------------~--> Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511 http://us.click.yahoo.com/sOykFB/k9VGAA/ySSFAA/i7folB/TM ---------------------------------------------------------------------~-> CodeCoffer the new code protection tool! http://www.delphicollection.com/public/CodeCoffer.htm --------------------------------------------------------------- Unsubscribe:[email protected] List owner:[email protected] --------------------------------------------------------------- Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/