Re: Component and Interface

"tonypaulday" <[email protected]>
Newsgroups gmane.comp.lang.delphi.programming
Message-ID <[email protected]>
May be wrong about this but I think Components do not use the AddRef 
and Release methods to do anything meaningful so if you override 
these with a simple refcounting scheme it may work...

Tony

--- In [email protected], Markus Ostenried 
<chef_007@g...> wrote:
> 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 ---------------------~-->
Free shipping on all inkjet cartridge & refill kit orders to US & Canada.
We have your brand: HP, Epson, Lexmark, Canon & more.
http://www.c1tracking.com/l.asp?cid=5510
http://us.click.yahoo.com/kP..SB/49VGAA/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/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.