GNOME Bugzilla – Bug 688180
GObject: Minor error in description of floating reference
Last modified: 2012-11-21 23:10:39 UTC
The description of GObject contains a code snippet, describing how the floating state of an object can be saved and restored. The code snippet is almost identical to code in GtkMenu, but one line is missing. /* save floating state */ gboolean was_floating = g_object_is_floating (object); g_object_ref_sink (object); /* protected code portion */ ...; /* restore floating state */ if (was_floating) g_object_force_floating (object); g_object_unref (object); /* release previously acquired reference */ The last few lines should be /* restore floating state */ if (was_floating) g_object_force_floating (object); else g_object_unref (object); /* release previously acquired reference */ If the object was floating, g_object_ref_sink() did not add a reference, and no reference shall be released. That's how it's done in gtk_menu_reparent().
Created attachment 228788 [details] [review] patch: GObject: Fix code snippet in description of floating reference.
Review of attachment 228788 [details] [review]: Ok, makes sense...it's worth noting the GTK+ code here hasn't changed since Tim's commit in 2005: fbb2e3f4f51a4c0ccc8f2bf511f4766293fc4af0 So let's assume it's right...