Re: Doubt about free or dont free



Gus Koppel wrote:
While the case of returned "const gchar *"s is rather simple, the real
problem to me is that the API docs are quite less explicit when it comes
to more complex objects than just string constants.

For instance, whether and how reference counts of objects related to
treeviews are changed by what GTK+ functions dealing with them remains
undocumented.

For instance: whether gtk_tree_view_set_model() changes the reference
counts of either the newly set or the replaced GtkTreeModel remains as
unclear as whether gtk_tree_view_get_selection() increases the reference
count of the selection object or not.

If I remember right the first function changes reference counts while
the 2nd one doesn't but I may be wrong on this. Frequent explicit checks
on object reference counts after many GTK+ functions are my only way to
make sure about this while developping.

I wish the API docs would be added a line for _every_ get- or set-
function, which explicitly notes whether and how reference counts of
associated objects are changed by that function.
 
IMHO especially the Gtk docs lack a lot here. For many methods one has
to look into the sources to find out wheter to unref or free. Problem is
that that docs don't use G_CONST_RETURN. Some examples:
gtk_*_get_model()
gtk_combo_box_get_popup_accessible()
gtk_widget_get_accessible()   (this one is 100% undocumented)

Filed as http://bugzilla.gnome.org/show_bug.cgi?id=311536
Please add others you find. 

Similiar problem applies to methods like

gtk_tree_model_get()

These functions should realy document wheter the ref object references returned in their out-params or not 
(they dont).

Stefan





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]