GNOME Bugzilla – Bug 681714
incorrect introspection annotation for vte_terminal_new
Last modified: 2012-08-24 19:17:29 UTC
As a general rule, the introspection annotations for constructor functions that return floating objects must effect transfer-ownership="none". (Otherwise, transfer-ownership="full" will cause the caller will assume that they own a reference to the returned object and so unref it later. However, the reference is actually floating and will likely become owned by someone else, e.g. a widget that does ref_sink. This leads to a spurious unref. transfer-ownership="none" ensures that the caller does a ref_sink.) VteTerminal is a descendant of GInitiallyUnowned, so the object returned by vte_terminal_new is floating. Thus the introspection annotation for vte_terminal_new should not contain (transfer full).
Created attachment 220958 [details] [review] Correct introspection annotation for vte_terminal_new
Looks ok to me, but I'm not an expert on introspection. Get someone from gobject-introspection to review; ok to commit if they think it's fine too.
Review of attachment 220958 [details] [review]: The comment about floating is right, but: ::: src/vte.c @@ +2488,3 @@ * Creates a new terminal widget. * + * Returns: (type Vte.Terminal): a new #VteTerminal object This should include (transfer none)
Created attachment 221057 [details] [review] Correct introspection annotation for vte_terminal_new Patch in response to review comment. However, as just discussed on #introspection, either patch is acceptable: the correct transfer mode for constructor functions is automatically worked out based on whether objects derive from GInitiallyUnowned. (See _get_transfer_default_return in maintransformer.py .) This explains why many, if not most, constructor functions in GTK+ have no (transfer ...) annotation. I can't commit, so I leave the choice of which patch to apply to whoever commits.
Review of attachment 221057 [details] [review]: Looks good, thanks!
Fixed on 0-34 and next.