Re: When is g_object_ref needed ?



Frédéric Terraza wrote:
Thanks. But there are still some mysteries. For example, this sequence :

my_pixmap = gdk_pixmap_new(...) ;
my_gc = gdk_gc_new(my_pixmap) ;
g_object_unref(my_pixmap) ;
g_object_unref(my_gc) ;

seems to lead to an error. I was told that g_object_unref(my_pixmap) ; would unref my_gc too. And effectively, if I delete the g_object_unref(my_gc) ; everything works fine.

Are there some others examples of dependancies in GDK/GTK ? (colormaps, for example ?)

Personally I have to say that I find this alarming, to me the
line:
    my_gc = gdk_gc_new (my_pixmap);
doesn't seem to imply that ownership of the newly created GdkGC
is given to the GdkDrawable. Furthermore it isn't documented
to in the api reference (at least not under gdk_gc_new() ).

I hate to ask you this but: Are you sure ? Can you reproduce
this in an isolated test case ?

Cheers,
                                   -Tristan



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