GNOME Bugzilla – Bug 693393
Add virtual functions with (transfer full) to support language bindings
Last modified: 2018-04-15 00:20:03 UTC
There are currently a handful of virtual function which are intended to return a new object but are marked as (transfer none). This causes problems because language bindings always sink newly created objects. Marshaling of the object from the language binding as a return value for a vfunc will then return a bad object because the sunk object is destroyed along with the language bindings wrapper (as the wrapper owns it). For example: class ToolMenuAction(Gtk.Action): def do_create_tool_item(self): return Gtk.MenuToolButton() APIs with virtual functions returning new objects should therefor only be marked as (transfer full). Doing this to the existing vfuncs would obviously cause breakage. This is a proposal to test the waters and see if the technique of adding alternate vfuncs for language binding support is acceptable. There are a few alternative ways to fix the problem: 1. Force users of language bindings to use workarounds. This also adds extra support when they run into the problem and file ticket/ask questions. 2. Add hacks to language bindings themself. This might be possible but it is tricky and would need to be done to all language bindings. The following is a list of problematic virtual functions for language bindings: Gtk.Action.create_menu Gtk.Action.create_menu_item Gtk.Action.create_tool_item Gtk.PrintOperation.create_custom_widget Gtk.PrintOperation.create-custom-widget (signal) Gladeui.EditorProperty.create_input Gladeui.BaseEditor.build_child? Gladeui.BaseEditor.build-child (signal)
Created attachment 235478 [details] [review] Add virtual functions with (transfer full) to support language bindings Add alternative virtual functions for create_menu, create_menu_item, and create_tool_item needed for language binding support. The new methods have "_transfer_full" as a suffix to explicity match that of the annotation. The existing vfuncs will continue to work and are API/ABI compatible. NOTE: This is currently does not fix the problem become it seems gi-scanner does not support renamed vfuncs. This is intended as a potential solution which needs GTK+ developer feedback before pursuing gi scanner problems.
Additionally: Gtk.CellRenderer.start_editing suffers the same problem.
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla. If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab: https://gitlab.gnome.org/GNOME/gtk/issues/new