Board index » delphi » Interfaceobject := nil doesn't call destructor.

Interfaceobject := nil doesn't call destructor.

Hello,

I have such TSection Object:

  TSections = class (TAutoIntfObject, ISections)
  private
    FSections: TInterfaceList;
  ...
In it's destructor I need to release TInterfaceList.

There is also a method in my program that calls:
  // Create Sections again
  FSections := nil;
  FSections := TSections.Create(Self);
  ..
I use this function to recreate the sections list.
First (but only first) time FSections := nil calls my destructor. After that
don't!

What's wrong?

Alex

 

Re:Interfaceobject := nil doesn't call destructor.


TAutointfObject constructor looks like "constructor Create(const TypeLib:
ITypeLib; const DispIntf: TGUID);"

Quote
>   TSections = class (TAutoIntfObject, ISections)
[..]
>   FSections := TSections.Create(Self);

I don't see how this can work...

Re:Interfaceobject := nil doesn't call destructor.


The type of FSessions has to be ISections, not TSections for reference
counting to work properly.

--
have fun

Binh Ly
www.techvanguards.com

Quote
"Alex Penner" <a...@c-studios.de> wrote in message

news:3aa4b755$1_1@dnews...
Quote
> There is also a method in my program that calls:
>   // Create Sections again
>   FSections := nil;
>   FSections := TSections.Create(Self);
>   ..
> I use this function to recreate the sections list.
> First (but only first) time FSections := nil calls my destructor. After
that
> don't!

> What's wrong?

> Alex

Re:Interfaceobject := nil doesn't call destructor.


Quote
> The type of FSessions has to be ISections, not TSections for reference
> counting to work properly.

Sure but FSections has been declared as TInterfaceList, so has to be freed
explicitly...
That code just does not compute (including that Create(Self))...

Other Threads