Is GtkStyle freed properly?

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

 



Hi list,

while testing some GTK code, I noticed that the style objects of widgets are not getting freed properly (or so it seems to me).

I'm no expert in GTK, so I might be totally wrong here or maybe the current behavior is intended as it is? So please feel free to enlighten me :)


What I think is happening is this:

gtk_widget_reset_rc_style() gets called during the creation of a new widget. This function calls gtk_rc_get_style() to get the new style for a widget. If the style differs from the current one, it gets applied by gtk_widget_set_style_internal, which then calls g_object_ref on it to get the ownership of the style for the widget.

That is all fine, apart from one thing. gtk_rc_get_style() returns either a new GtkStyle object or an already existing cached one. In case it returns a new style object, the ref count is 1 (isn't?) and unfortunately nobody will call g_object_unref for it. 

That is because gtk_widget_reset_rc_style() does not now, if it just got a new ownership (in case of a new GtkStyle object) or not (in case when it gets a cached GtkStyle object). 

I think this behavior of gtk_rc_get_style(), to return new objects and cached ones, is the root of the problem. If it would always pass the ownership of the returned style to the caller (e.g. by calling g_object_ref on cached styles), the caller could then always call g_object_unref to "free" it.


Any thoughts?




Best regards,

Henry


-- 
Hi! I'm a .signature virus! Copy me into your
~/.signature to help me spread!

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux