GNOME Bugzilla – Bug 616893
Add '(transfer none)' annotation to return value of g_filter_(input/output)_stream_get_base_stream
Last modified: 2015-02-07 17:00:44 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.
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'.
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.
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.
The following fix has been pushed: d6eab71 Adds annotations to g_filter_(input/output)_stream_get_base_stream
Created attachment 161464 [details] [review] Adds annotations to g_filter_(input/output)_stream_get_base_stream Fixes bug 616893
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]