Re: Widget destroy process
- From: John Cupitt <john cupitt ng-london org uk>
- To: Stephane Demurget <demurgets free fr>
- Cc: gtk-list gnome org
- Subject: Re: Widget destroy process
- Date: Wed, 05 Sep 2001 15:17:12 +0100
Hi Stephane,
Stephane Demurget wrote:
> I've just written a top-level widget, but I've got some troubles with
> the destroy process. I've read the ref counting doc, so I know there's
> some extra work needed by a top-level widget to be done and that's why
> ref counting don't work for it. So I need to explicitly destroy it.
This took me ages to get right too :-( I'm sure some gtk-guru can give a better
answer, but the rules seem to be:
- make instances with _new(), destroy those instances with
gtk_object_destroy()
- if you're a container widget (ie. you contain other widgets),
when you are given a new child, you need to do:
gtk_object_ref( obj );
gtk_object_sink( obj );
- when you loose a child, you need to do:
gtk_object_unref( obj );
- when you are destroyed, you need to remove all of your children
(call your remove_child() thing repeatedly)
- some clean up can be delayed until _finalize() if that helps
If you subclass your container from GtkContainer (not always possible), it does
most of this stuff for you.
John
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]