Re: GObject reference counting / lack of "sink" issue



On Wed, Nov 09, 2005 at 04:23:42PM +0100, Michael Natterer wrote:
> On Fri, 2005-09-30 at 01:38 +0200, Tim Janik wrote:
> 
> (snip)
> 
> > so for a change, i'd like to suggest introducing extra API (and do some slight
> > deprecations) for this and apprechiate people's comments on it:
> > 
> > /* ref() and clear floating flag (#1) */
> > GObject*    g_object_ref_sink       (GObject *object);
> > 
> > /* figure whether floating flag is set */
> > gboolean    g_object_is_floating    (GObject *object);
> > 
> > /* intended for object implementations only, sets the floating flag */
> > void        g_object_force_floating (GObject *object);
> 
> (more API details snipped)
> 
> 
> Better a late response than none at all...
> 
> I would very much appreciate such an API for GObject. GIMP is one of the
> examples that contain a 1:1 copy of GtkObject's "floating" feature.
> Having it in GObject would allow us (and probably many other projects)
> to get rid of this code duplication.

since i balked a bit, i think i'd like to rescind my complaint.

in my original reply i somehow thought that the default GObject constructor
would yield a floating object, which seemed
like a recipe for compatibility headaches.

i think that the example i pointed out, g_value_set_object()
is already confusing with regard to sinking.
and i agree that there are definitely benefits to consolidating
the floating stuff.
(otoh, the more i think about the floating flag,
the less i really think it helps anyone, but
i does save a few g_object_unrefs i guess, shrug)

cheers,
dave



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