Re: toplevel g_object_unref segv

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 */


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