Re: Transfer modes for ref-counted return values that may have a floating reference



On 09/04/18 15:32, Philip Withnall wrote:
On Sat, 2018-03-31 at 00:27 +0100, Phil Clayton wrote:
Based on the description of transfer modes at
https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations/
I was assuming that bindings are expected to do the following for a
ref-counted return value that may have a floating reference:

if transfer-ownership=full: take over ref
if transfer-ownership=none: ref-sink and take over ref

(quoting from https://bugzilla.gnome.org/show_bug.cgi?id=657202#c1)
Is this still the case?  Or has it changed to:

if transfer-ownership=full, floating=true: ref-sink and take over ref
if transfer-ownership=full, floating=false: take over ref
if transfer-ownership=none: ref-sink and take over ref

Grepping through gobject-introspection.git, it looks like (transfer
floating) is handled entirely as an alias for (transfer none). It does
not have any different behaviour from (transfer none).

So we still have the first situation:

If (transfer full): take over ref
If (transfer none): ref-sink and take over ref
If (transfer floating): ref-sink and take over ref

Thanks for confirming.

I was finding that g_object_new_with_properties was returning a floating reference despite having the annotation (transfer full) on the return value. On further investigation, the function does not return a reference for the caller to assume ownership for any subclass of GInitiallyUnowned so is not actually introspectable. I've raised
https://bugzilla.gnome.org/show_bug.cgi?id=795025

Phil


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