Re: Problems with un-owned objects passed to closures in pygobject (gtk_cell_renderer_text_start_editing)
- From: Simon Feltman <s feltman gmail com>
- To: Simon McVittie <simon mcvittie collabora co uk>
- Cc: gtk-devel-list gnome org
- Subject: Re: Problems with un-owned objects passed to closures in pygobject (gtk_cell_renderer_text_start_editing)
- Date: Tue, 5 Feb 2013 05:33:01 -0800
For completeness, the two major problems are as follows:
This is a vfunc implementation which the gtk internals are basically expecting a floating ref from. Using the standard scheme just listed, we sink and own the created MenuToolButton. The held widget is then finalized at the end of the vfunc, returning an invalid object back to the caller. If we add an extra ref we get a leak because the method is marked as transfer-none. Example:
class ToolMenuAction(Gtk.Action):
def do_create_tool_item(self):
return Gtk.MenuToolButton()
This is a very simple case of a widget as a parameter being marshaled as an in arg to a callback. But because the gtk internals have not yet sunk the floating ref for the "editable" parameter, PyGObject will do so. By the time the callback is finished, the editable will be finalized leaving gtk with a bad object. It should really just be adding a safety ref during the lifetime of the wrapper and not mess with the floating flag.
def on_view_label_cell_editing_started(renderer, editable, path):
print path
renderer = Gtk.CellRendererText()
renderer.connect('editing-started', on_view_label_cell_editing_started)
-Simon
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]