Styles, unref'ing, and free'ing.




What is the correct way to get rid of a style once you're finished
with it?  I noticed in the gtk source code that gtk_style_copy and
most of the others call gtk_style_new which allocates new memory with
g_new0 as one of the first things it does.  It stands to reason then
that it would need to be g_free'd when the programmer is done with it.

But when I use gtk_style_unref() and g_free(some_style) I end up
getting piles of failed assertions (the assertion is style->ref_count
> 0 I believe).

How is this handled?  What's the whole story with ref counts?  I never
have seen any docs anywhere on how that works, but when I hear about
reference counts, it makes me think that when the reference count
becomes 0, the item would get "garbage collected" or something
similar.  (That's why I thought gtk_font_unref() might be what I was
looking for)

Alternatively, is this handled through the widget the style is
attached to?  When the widget gets destroyed, does the style die too?
If so, then how would it work to set one structure as the style for
multiple widgets?  (Which  might die at different times?)

Any pointers (no pun intended) would be appreciated.
-- 
David Allen
http://opop.nols.com/
----------------------------------------
A slipping gear could let your M203 grenade launcher fire when you
least expect it. That would make you quite unpopular in what's left of
your unit. 
	- The Army's magazine of preventive maintenance.



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