[gst-devel] FW: GObject life cycle

Baker, Steve SBaker at CHELLO.com
Sat Sep 29 12:01:11 CEST 2001


This is pretty much what we're doing but it doesn't hurt to have it spelt
out.

cheers

-----Original Message-----
From: Havoc Pennington [mailto:hp at redhat.com]
Sent: 29 September 2001 20:47
To: Baker, Steve
Cc: 'gtk-list at gnome.org'
Subject: Re: GObject life cycle



Hi,

I'll take a shot at this though I didn't read the last few emails
discussing The Plan so I'm not sure on all the details.

"Baker, Steve" <SBaker at CHELLO.com> writes: 
> So what I need to know is:

I believe GtkObject::destroy and GObject::dispose are basically the
same thing, in the end, except that dispose is not a signal.
You're supposed to use weak references rather than connect to dispose.
Weak references are notified at dispose-time.

> - what needs to go in the dispose function?

Reset your object to its "uninitialized" state, that is, drop all
references to other objects you have acquired over the lifetime of the
object. Your object should remain valid, just drop refs held to other
objects. Remember dispose can happen more than once, but should break
any refcount cycles that exist each time it's run.  GObject
automatically notifies weak refs and disconnects all signal handlers
in dispose.

> - does the parent's dispose need to be called?

Yes.

> - what needs to go in the finalize function?

Free memory, unref objects. This is called once when the refcount
reaches 0.

> - does the parent's finalize need to be called?

Yes.

> - is that all there is to it?

Pretty much. It's just "break refcount cycles in dispose" and 
"free memory in finalize"

Havoc






More information about the gstreamer-devel mailing list