On Sat, 17 Dec 2005, Dave Benson wrote:
On Thu, Dec 15, 2005 at 05:07:34PM +0100, Tim Janik wrote:
On Thu, 15 Dec 2005, Dave Benson wrote:
[long discussion cut]
this thread never really addressed my concern,
which was that this makes it so that container classes
before 2.10 have one style, and >=2.10 have another.
considering that this change is trying to simplify
memory management, i'm dubious.
as i origianlly mentioned, my example is
g_value_set_object()
which clearly should ref_sink(), but clearly cannot
for abi compatiblity reasons (though i'm not exactly going to
be shocked when a patch goes in that does it anyways...)
you're right that simply changing that function take over one
reference for floating objects would break existing user code.
compatibly, you can add extra value setters that properly sink
though, if you think adding that API is worthwhile.
and you could then deprecate the old API if you think that'd be wise.
(i'm intentionally leaving this open)
so... do you agree that if you could, g_value_set_object()
would ref-sink?
no, which is why i left this open.
even if GObject would have supported a floating reference right from
the start, it would have been a hard call to make whether
g_value_set_object() takes a floating reference or not.
the reason is that depending on the usage context of the GValue, you
want it to "own" the object or not which sometimes is hard to tell.
in practice, you want a function sink the initial floating reference
if it is likely/often to be used in contexts like:
function (g_object_new(...));
which clearly is the case for widgets and containers:
container_add (gtk_widget_new (...));
or closures and signals:
signal_connect (closure_new (...));
but not neccessarily values:
value_set (g_object_new (...));
at least i haven't written the latter too often.
there really is no other reason for this, floating references are
only useful as a C convenience as the reference documentation states:
http://developer.gnome.org/doc/API/2.0/gobject/gobject-The-Base-Object-Type.html#floating-ref
- dave
---
ciaoTJ
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-devel-list