After some headache with my gtk C++ classes I've found with a small test program this fact about the gobject references:
Window Creation: 1 Sink: 2 End: 1 Label Creation: 1 Sink: 1 End: 0 It seems that window derived widgets are created with a not floating reference, so they should be handled differently, are window classes the only GTK objects created with a strong reference or there are also other widgets? The strange thing is that both GtkWindow and GtkLabel derive from GObjectInitiallyUnowned. And that if I use: g_object_is_floating() to avoid the additional reference on the window object when I unref it I get: (<unknown>:29976): GLib-GObject-WARNING **: instance with invalid (NULL) class pointer (<unknown>:29976): GLib-GObject-CRITICAL **: g_signal_handlers_destroy: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed End: -1 Here is the code (tested with GTK 2.12): #include <gtk/gtk.h> int main() { gtk_init(NULL, NULL); GtkWindow *w = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget *l = gtk_label_new("Test"); printf("Window\nStart: %d ", G_OBJECT(w)->ref_count); g_object_ref_sink(G_OBJECT(w)); printf("Sink: %d ", ((GObject *)w)->ref_count); g_object_unref(G_OBJECT(w)); printf("End: %d\n", ((GObject *)w)->ref_count); printf("Label\nStart: %d ", G_OBJECT(l)->ref_count); g_object_ref_sink(G_OBJECT(l)); printf("Sink: %d ", ((GObject *)l)->ref_count); g_object_unref(G_OBJECT(l)); printf("End: %d\n", ((GObject *)l)->ref_count); } -- Ing. Gabriele Greco, DARTS Engineering Tel: +39-0105761240 Fax: +39-0105760224 s-mail: Via G.T. Invrea 14 - 16129 GENOVA (ITALY) _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list