Re: Problem swapping GtkScrolledWindow contents on the fly



On Fri, Dec 25, 2009 at 01:01:36AM +0000, Andrew Wood wrote:
Thanks Tristan. I think I follow what you're saying...

The call to  gtk_container_remove is decrementing the ref count so  
generalpage becomes NULL?

Is there a way to "up" the count immediately prior to calling   
gtk_container_remove

g_object_ref(), please refer to the GObject tutorial

http://library.gnome.org/devel/gobject/stable/gobject-memory.html

Generally, you should not "up the count" just prior
gtk_container_remove().  If you own an object, you should reference it
and only release your reference with g_object_unref() when you are done
with the object.  

The floating reference trick used by widgets just simplifies coding in
the common situation when the object (a) will end up owned by some other
object you own so it's sufficient that you refer this other object or
(b) you are content with the object disappearing any time (possibly
both).

In the general case simplifications don't work and you must follow the
rules.

Yeti




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