gtk_tree_model_get() doing copies



hi jonathan,

i think we should change:

/**
 * gtk_tree_model_get:
 * @tree_model: a #GtkTreeModel
 * @iter: a row in @tree_model
 * @Varargs: pairs of column number and value return locations, terminated by -1
 *
 * Gets the value of one or more cells in the row referenced by @iter.
 * The variable argument list should contain integer column numbers,
 * each column number followed by a place to store the value being
 * retrieved.  The list is terminated by a -1. For example, to get a
 * value from column 0 with type %G_TYPE_STRING, you would
 * write: gtk_tree_model_set (model, iter, 0, &place_string_here, -1),
 * where place_string_here is a gchar* to be filled with the string.
 * If appropriate, the returned values have to be freed or unreferenced.
 *
 **/
void
gtk_tree_model_get (GtkTreeModel *tree_model,
                    GtkTreeIter  *iter,
                    ...)

into a not-copying variant. that is, pass G_VALUE_NOCOPY_CONTENTS
instead of 0 into G_VALUE_LCOPY() in gtk_tree_model_get_valist().
i just did this for g_object_get() as well, mainly for three reasons:
1) to preserve compatibility with gtk_{object|widget}_get() which use
   g_object_get() now and never copied the arguments
2) because the caller usually needs to acquire a lock in threaded environments
   before using getters on objects (such as the global GDK lock) and also knows
   to _ref() or dup retrived values if he wants to retain validity across
   setters
3) we don't usually duplicate or reference returned values in other getters
   either

btw, this also affects signal return values that are ref-counted or allocated.
unless the result should be duped/refed, G_SIGNAL_TYPE_STATIC_SCOPE has to
be ORed with the return value type upon creation of the signal.
(though that shouldn't affect us much, afaik, we use no signals yet
that return alloced/refed structs)

---
ciaoTJ






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