Re: g_object_add_toggle_ref

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

 



On Sat, 2017-06-03 at 15:37 +0200, Stefan Salewski wrote:

What is a bit strange is

void
g_object_add_toggle_ref (GObject       *object,
			 GToggleNotify  notify,
			 gpointer       data)
{
  ToggleRefStack *tstack;
  guint i;
  
  g_return_if_fail (G_IS_OBJECT (object));
  g_return_if_fail (notify != NULL);
  g_return_if_fail (object->ref_count >= 1);

  g_object_ref (object);

So after a call of g_object_add_toggle_ref() ref_count of an object is
always greater or equal to two? But how can now that value drop ever
again below 2? When a new references is added, it increases, and when
that references is removed, the value is decreased. But never below 2
this way? It is a bit confusing indeed.

More confusing is, that g_object_ref_sink () seems to exist since
gobject release 2.10, while g_object_add_toggle_ref () seems to exists
already since 2.8.

And, for my understanding of English wording, the documentation of 
g_object_ref_sink() contradicts even itself:

https://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type
.html#g-object-ref-sink


"Increase the reference count of object
, and possibly remove the
floating reference, if object
 has a floating reference.

In other words, if the object is floating, then this call "assumes
ownership" of the floating reference, converting it to a normal
reference by clearing the floating flag while leaving the reference
count unchanged.  If the object is not floating, then this call
adds a new normal reference increasing the reference count by one."

I assume, that the second part is correct. Maybe the first sentence
should be something like "Increase the reference count of object
, OR possibly"

So it will be not that easy to get fully working Garbage Collector
support.

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list




[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux