Re: gobject bug?
- From: Tristan Van Berkom <vantr touchtunes com>
- To: tom <tom dbservice com>
- Cc: gtk-devel-list gnome org
- Subject: Re: gobject bug?
- Date: Thu, 09 Jan 2003 11:18:57 -0500
I never wrote a "fundamental" type
object (always derived from GObject)
but I know that GBaseFinalizeFunc
and GClassFinalizeFunc are rarely
used. the baseinit should be called
once when your "type" is first instanced.
basefinalize should be called when
you're sure not to instance "type"
anymore. and usualy you dont store
allocated datum in your Class
struct but if you do ... class_finalize
is where you should free it.
strangly enough; the document that helped
me the most and pointed me to the right
places is about writing gtk+ language
bindings:
http://www.gnome.org/~james/language-bindings/
(for info on marshallers, types, closures
etc...)
good luck!
-Tristan
tom wrote:
>
> i created a fundamental object 'foo':
>
> GType
> foo_get_type (void)
> {
> static GType type = 0;
> static const GTypeFundamentalInfo finfo = {
> G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE |
> G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE
> };
>
> if (!type)
> {
> static const GTypeInfo info = {
> sizeof (fooClass),
> (GBaseInitFunc) foo_base_init,
> (GBaseFinalizeFunc) foo_base_finalize,
> (GClassInitFunc) foo_class_init,
> (GClassFinalizeFunc) foo_class_finalize,
> NULL,
> sizeof (foo),
> 0,
> (GInstanceInitFunc) foo_instance_init,
> NULL
> };
>
> g_type_init ();
>
> type = g_type_register_fundamental (g_type_fundamental_next (), "foo",
> &info, &finfo, 0);
>
> g_assert (G_TYPE_IS_FUNDAMENTAL (type));
> }
>
> return type;
> }
>
> foo *
> foo_new ()
> {
> g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __FUNCTION__);
> return (foo *) g_type_create_instance (FOO_TYPE);
> }
>
> void
> foo_destroy (foo * f)
> {
> g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __FUNCTION__);
> g_type_free_instance ((GTypeInstance *) f);
> }
>
> static void
> foo_base_init (fooClass * g_class)
> {g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __FUNCTION__);}
>
> static void
> foo_base_finalize (fooClass * g_class)
> {g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __FUNCTION__);}
>
> static void
> foo_class_init (fooClass * g_class, gpointer class_data)
> {g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __FUNCTION__);}
>
> static void
> foo_class_finalize (fooClass * g_class, gpointer class_data)
> {g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __FUNCTION__);}
>
> static void
> foo_instance_init (foo * instance, fooClass * g_class)
> {g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __FUNCTION__);}
>
> but if i do this:
>
> main()
> {
> foo *f = foo_new();
> foo_destroy(f);
> sleep(2);
> return 0;
> }
>
> i get:
>
> (process:6270): foo-DEBUG: foo_new
> (process:6270): foo-DEBUG: foo_base_init
> (process:6270): foo-DEBUG: foo_class_init
> (process:6270): foo-DEBUG: foo_instance_init
> (process:6270): foo-DEBUG: foo_destroy
>
> and thats all... why are the functions 'foo_class_finalize' and
> 'foo_base_finalize' not called ?
>
> thanks
> tom
>
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]