[Lazarus] IUnknown and reference counting

Sven Barth pascaldragon at googlemail.com
Thu Mar 21 14:38:40 CET 2013


Am 21.03.2013 14:23, schrieb Kostas Michalopoulos:
> Yes, that is what i mean with "topmost" type: if you look at the 
> inheritance as a tree, TInterfacedObject is the topmost (or root, if 
> you think of it as an upside-down tree) of the type hierarchy. In this 
> code
>
>   type
>     IBlah = interface ... end;
>     TBlah = class(TInterfacedObject, IBlah) ... end;
>
> TBlah is an IBlah, so i'd expect it to behave like IBlah.

And it behaves like an IBlah, because you can assign a TBlah to every 
variable or parameter that expects a IBlah.
The point however is that the compiler only inserts calls to AddRef and 
Release (which are provided by the base interface IUnknown/IInterface 
and of which every (COM) interface is derived) if the variable you work 
with is of an interface type.

Regards,
Sven




More information about the Lazarus mailing list