After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 688180 - GObject: Minor error in description of floating reference
GObject: Minor error in description of floating reference
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: docs
2.35.x
Other Linux
: Normal trivial
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-11-12 15:59 UTC by Kjell Ahlstedt
Modified: 2012-11-21 23:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch: GObject: Fix code snippet in description of floating reference. (826 bytes, patch)
2012-11-12 16:10 UTC, Kjell Ahlstedt
committed Details | Review

Description Kjell Ahlstedt 2012-11-12 15:59:45 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().
Comment 1 Kjell Ahlstedt 2012-11-12 16:10:40 UTC
Created attachment 228788 [details] [review]
patch: GObject: Fix code snippet in description of floating reference.
Comment 2 Colin Walters 2012-11-21 23:09:54 UTC
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...