Destructor semantics

Max Samukha spambox at d-coding.com
Fri Aug 13 11:29:33 PDT 2010


On 08/13/2010 12:07 AM, Michel Fortin wrote:

> Here is a real-world example: the D/Objective-C bridge use a class
> destructor/finalizer to release the Objective-C counterpart of a wrapper
> (by calling the release method on the Objective-C object). The
> Objective-C object is not something I can allocate with the D GC, and
> the D counterpart wouldn't be very usable if it was not managed by the D
> GC. So finalization does the cleanup, and that works just fine.
>
> I wonder what QtD does, but it's probably something similar too.
>

It does the same. A Qt object will be destroyed when the wrapper is GCed 
(if the Qt object is owned by D and does not have references in C++)

We tried to impose management of all QtD objects on the user but that 
proved to be a bad idea. The exception is QObject. In Qt QObjects are 
arranged in trees. When the root node is destroyed all its children are 
destroyed as well. GC is disabled for QObjects.



More information about the Digitalmars-d mailing list