[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk-devel
Subject:    Re: toplevel g_object_unref segv
From:       Owen Taylor <otaylor () redhat ! com>
Date:       2002-02-28 19:56:10
[Download RAW message or body]


Carlos Romero <caberome@bellsouth.net> writes:

> this gives a segv in g_datalist_set_data_full()
> line:218 if (list->id == key_id)
> list = (GData *) 0xaaaaaaaa
> intel linux-2.4.17 gcc-2.95.3
> 
> GtkWidget* w;
> gtk_init (&argc, &argv);
> w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> /* w = gtk_invisible_new() */
> gtk_widget_show(w);
> g_object_unref(G_OBJECT(w));

Yes, it's illegal. You don't own a refcount on the window. A newly
created window owns its own initial refcount, and will release it
when gtk_object_destroy() is called.

The safe way to obtain a refcount on a newly created object is:

 object = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 gtk_object_ref (object);
 gtk_object_sink (object);  /* Does nothing, since the window already cleared the floating flag */

Regards,
                                        Owen
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic