On Wed, Feb 02, 2005 at 02:09:12PM -0800, Adrian E. Feiguin wrote: > What's wrong with floating objects? I have created and array and matrix > class, and I play with reference counting. Sometimes I need to create a > temporary object that I free right away after some manipulation, and I > always get gobject to complain that ... > > Gtk-WARNING **: A floating object was finalized. This means > that someone > called g_object_unref() on an object that had only a floating > reference; the initial floating reference is not owned by anyone > and must be removed with gtk_object_sink() after a normal > reference is obtained with g_object_ref(). > > Why would I want to sink it? Can anybody explain the logic behind it? > It's not clear to me from the documentation, and it's not practical for > my application. Thanks! Floating references are explained here (see Description): http://developer.gnome.org/doc/API/2.0/gtk/GtkObject.html For objects like arrays and matrices I would recommend to derive them directly from GObject (no floating references, normal reference counting) instead of GtkObject (floating references) because floating references are more or less a hack that saves lots of g_object_unrefs() with some usage patterns. However, your usage patterns seem to be quite different. If you really want to derive from from GtkObject but don't like floating references, it should be possible to make all constructors (sometype_new()) to do g_object_ref() and gtk_object_sink() themselves, and thus returing an object with one normal non-floating reference. I've never tried that (and it doesn't catch all construction code paths, but one normally doesn't create objects directly with g_object_new(SOMETYPE, ...)). Yeti -- Dynamic IP address is not a crime. _______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list