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 656205 - Any static method who returns floating ref object should be marked as (transfer none)
Any static method who returns floating ref object should be marked as (transf...
Status: RESOLVED DUPLICATE of bug 657202
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2011-08-09 11:13 UTC by Peteris Krisjanis
Modified: 2015-02-07 16:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for changing annotation to transfer none for gst_element_factory_make (988 bytes, patch)
2011-08-09 11:14 UTC, Peteris Krisjanis
needs-work Details | Review

Description Peteris Krisjanis 2011-08-09 11:13:30 UTC
Problem: currently using lot of Gstreamer 0.11 classes methods which returns GstObjects are not possible with Gobject Introspection because objects get destroyed right after their creation. For example this Python script segfaults because of this:

from gi.repository import Gst
Gst.init(None)
element = Gst.ElementFactory.make("audioconvert", "aconvert")
print element.name

Solution: all values which returns floating ref objects (GstObject for example) should have transfer ownership set to none. Object has his floating reference sinked in bindings (pygobject for example). See more http://developer.gnome.org/gobject/unstable/gobject-The-Base-Object-Type.html#floating-ref

I might be wrong, but as far my research goes floating refs should be sinked this way because it otherwise is left floating and therefore it goes away. Transfer full means that Gstreamer leaves to itself to add ref, but it doesn't work that way.

I add patch which changes transfer mode for Gst.ElementFactory.make() method. With this element is accessible and aren't destroyed before time has come. I have tried this successfully for Gst.Bin.new() and Gst.parse_bin_from_description too, which both segfaulted with transfer full.
Comment 1 Peteris Krisjanis 2011-08-09 11:14:22 UTC
Created attachment 193483 [details] [review]
Patch for changing annotation to transfer none for gst_element_factory_make
Comment 2 Sebastian Dröge (slomo) 2011-08-10 09:24:30 UTC
Comment on attachment 193483 [details] [review]
Patch for changing annotation to transfer none for gst_element_factory_make

As discussed on IRC this is not a good solution because it's conceptionally wrong. The return value is owned by the caller and the caller has to unref it after usage.

pygobject has some special magic to handle floating refs which makes it work if transfer none is used but a better solution should be found on the GI side. For example by adding a new (transfer floating) annotation
Comment 3 Sebastian Dröge (slomo) 2011-08-25 07:35:29 UTC
Conceptionally functions returning floating refs owned by the caller should be either (transfer full) or a new (transfer floating), (transfer none) doesn't make any sense.

The same goes for constructors, they should be (transfer full), which currently is done implicit... or a new (transfer floating)
Comment 4 Colin Walters 2011-08-25 17:11:27 UTC
(In reply to comment #2)

> pygobject has some special magic to handle floating refs which makes it work if
> transfer none is used but a better solution should be found on the GI side. For
> example by adding a new (transfer floating) annotation

If it makes you happy, we can add "floating" as an alias for "none".  We also kind of desperately need better docs of course =(

However for bindings, we already tell them that they have to specially handle floating refs.

For library authors, the story is that they're returning a floating reference - a special case.

See also https://bugzilla.gnome.org/show_bug.cgi?id=657202
Comment 5 Sebastian Dröge (slomo) 2011-08-26 08:18:13 UTC
floating as an alias for none would at least improve the API docs but for bindings this would still leave the weird special casing for GInitiallyUnowned and the transfer annotation. IMHO what happens here should be made more explicit, like suggested in bug #657202
Comment 6 Colin Walters 2011-11-23 00:26:07 UTC

*** This bug has been marked as a duplicate of bug 657202 ***
Comment 7 André Klapper 2015-02-07 16:58:30 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]