[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Attaching Data to Objects - when is destroy invoked
- From: Kent Schumacher <kent structural-wood com>
- To: gtk-app-devel-list redhat com
- Subject: Re: Attaching Data to Objects - when is destroy invoked
- Date: Thu, 26 Aug 1999 08:37:23 -0500
Havoc Pennington wrote:
> On Wed, 25 Aug 1999, Kent Schumacher wrote:
> >
> > My feeling about how an 'object' should behave is that it should
> > call the destroy method of user attached data whenever the object
> > is destroyed.
> >
> > I could use some educating about the rational behind this behaviour.
> >
>
> The insight you need is that your data is destroyed when an object is
> _finalized_, that is, when its reference count reaches 0. Objects start
> with a count of 1; if you add them to the container, the container
> "assumes" the count and unrefs the object when the container is destroyed.
> Destruction renders an object "unusable" but still "safe," when the count
> finally reaches 0 then the object is actually freed ("finalized").
>
> My book's sample chapters talk about this some,
> http://pobox.com/~hp/gnome-app-devel.html
>
> Anyway, basically you own the object's initial refcount until you hand it
> to a container, so you need to unref the object instead of destroying it.
>
> Havoc
>
Thanks Havoc - I loved the accuracy of your phrase 'the insight you need'.
As usual your comment was dead on, and you have solved my problems for me.
I had read your section on finalization on-line, but it is never the same as having
a book in front of me. Can't wait for the book to come out.
Thanks,
Kent
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]