Component and Interface
Markus Ostenried <[email protected]>
| Newsgroups | gmane.comp.lang.delphi.programming |
|---|---|
| Message-ID | <[email protected]> |
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 Natural Vitamins for Good Prostate & Male Health. $28.97
http://www.challengerone.com/t/l.asp?cid=2865&lp=prosta2.html
http://us.click.yahoo.com/qJIe0D/89VGAA/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/