Re: Where do I hook in a GObject's finalize method?



John Palmieri <johnp martianrock com> writes:

> Hello,
> 
> I am a bit confused with the way GObjects should be finalized.  All of
> the GObjects and GtkObjects I have looked at so far ignore the GTypeInfo
> structure's finalize entrys by sending in NULL and instead set
> object_class->finalize = some_object_finalize; in the init_class
> method.  
> 
> Which is the correct way to handle this? In the type info or the
> class_init method?  Also when should I use the base_init and
> base_finalize elements in the GTypeInfo structure?

The GTypeInfo's structure's field is for finalization of the
_class_ ... not something of interest unless you are doing
dynamically loadable/unloadable object types.

base_init (and for unloadable classes base_finalize) are quite
specialized; the one place I can point to for their use is
something like gtk+/gtk/gtkcontainer.c:gtk_container_base_class_init(),
where when a new subclass is derived from GtkContainer, it
should by default get NULL for the set_child_property / 
get_child_property fields.

[ The reason for this is that the gtk_container_child_set()
  will always call the set_child_property() function for the
  parent class where the child was installed, not for the
  class of the widget itself ]

Regards,
                                        Owen



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