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 616893 - Add '(transfer none)' annotation to return value of g_filter_(input/output)_stream_get_base_stream
Add '(transfer none)' annotation to return value of g_filter_(input/output)_s...
Status: RESOLVED FIXED
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: 2010-04-26 21:44 UTC by Eduardo Lima Mitev
Modified: 2015-02-07 17:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch to fix this (1.43 KB, patch)
2010-04-26 21:53 UTC, Eduardo Lima Mitev
none Details | Review
patch to fix it (756 bytes, patch)
2010-04-27 16:16 UTC, Eduardo Lima Mitev
none Details | Review
Adds annotations to g_filter_(input/output)_stream_get_base_stream (750 bytes, patch)
2010-05-19 15:59 UTC, Johan (not receiving bugmail) Dahlin
committed Details | Review

Description Eduardo Lima Mitev 2010-04-26 21:44:19 UTC
Without this annotation, the base stream object can be destroyed if used in more than one scope. Consider the following Javascript code:

---
const Gio = imports.gi.Gio;

function foo (filter_stream) {
    let base_stream = filter_stream.get_base_stream ();

    // after leaving this scope, 'base_stream' will be unref'd
    // (because (transfer full) is default), corrupting the
    // 'filter_stream'
}

let file = Gio.file_new_for_path ("/proc/stat");
let input_stream = file.read (null);

let filter_stream = new Gio.FilterInputStream ({base_stream: input_stream});

foo (filter_stream);

// this will get an already destroyed reference
let same_stream = filter_stream.get_base_stream ();

log (same_stream);
---

And spits a message 'conflicting gtypes for prototype (null) (0) (was GLocalFileInputStream (...))'. 
A simple '(transfer none)' annotation would fix this.
Comment 1 Eduardo Lima Mitev 2010-04-26 21:53:56 UTC
Created attachment 159647 [details] [review]
patch to fix this

Tiny patch adding '(transfer none)' annotation to return value of both 'g_filter_input_stream_get_base_stream' and 'g_filter_output_stream_get_base_stream'.
Comment 2 Dan Winship 2010-04-27 13:09:18 UTC
you don't need to argue your case at great length, or write a big commit message in cases like these. When (transfer none) is needed but missing, it's pretty unambiguous.

however, glib isn't currently being annotated directly. you need to submit a patch to add annotations for these functions to the file gir/gio-2.0.c in the gobject-introspection module.
Comment 3 Eduardo Lima Mitev 2010-04-27 16:16:14 UTC
Created attachment 159704 [details] [review]
patch to fix it

This new patch adds the annotations in /gir/gio-2.0.c of gobject-introspection module.

Dan, thanks for your clarification.
Comment 4 Johan (not receiving bugmail) Dahlin 2010-05-19 15:59:23 UTC
The following fix has been pushed:
d6eab71 Adds annotations to g_filter_(input/output)_stream_get_base_stream
Comment 5 Johan (not receiving bugmail) Dahlin 2010-05-19 15:59:32 UTC
Created attachment 161464 [details] [review]
Adds annotations to g_filter_(input/output)_stream_get_base_stream

Fixes bug 616893
Comment 6 André Klapper 2015-02-07 17:00:44 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]