Re: Unref-ing a dummy GtkWindow -> crash



On Fri, 2007-12-07 at 23:49 +0100, ole nielsby pils org wrote:
> I'm trying implementing dynamic object creation for a language binding.
> First of all, I need to be able to simply create objects without specifying
> attributes, and free them.
> 
> This seems this works for some types (GtkAction) but not for
> others (GtkWindow).

The difference is that GtkWindow (and GtkWidget, etc.) inherit from
GInitiallyUnowned.  Initially-unowned objects are born with a reference
count of 0 and a "floating" reference that is sunk when they are added
to a container.

In your code you need to

g_object_ref_sink (x);

before unreffing it.

Ed



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