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 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







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]