Re: Writable array returned from gtk_tree_path_get_indices()
- From: Tadej Borovšak <tadeboro gmail com>
- To: stefw gnome org
- Cc: "gtk-devel-list gnome org" <gtk-devel-list gnome org>
- Subject: Re: Writable array returned from gtk_tree_path_get_indices()
- Date: Thu, 7 Oct 2010 23:29:56 +0200
Hi.
2010/10/7 Stef Walter <stef-list memberwebs com>:
> Is the integer array returned from gtk_tree_path_get_indices() writable
> by design? Or should it be treated as readonly?
You should definitely not modify values in returned array, since this
central part of GtkTreePath. Currently, modifying parts of this array
is the same as moving your path using gtk_tree_path_(next|prev)(), but
if internal structure of GtkTreePath changes, you'll be in trouble.
> Some stuff like GtkTreeModelSort and GtkTreeModelFilter write to this
> index array, but those may be liberties taken by gtk+ internally.
Quickly looking at the code I would say that this is indeed the case
here. Directly modifying values avoids some type checking, which
speeds up some of the operations.
> Perhaps we would change the return values for the following to 'const
> gint*':
>
> gtk_tree_path_get_indices ()
> gtk_tree_path_get_indices_with_depth ()
>
> If not by design, I'll file a bug, and patch.
I think that minimal thing to do here is to update docs to something
like this: "Returns the current indices of path. This is an array of
integers, each representing a node in a tree. This value should not be
freed and members of array should not be modified." Filling a bug is
definitely the way to go IMHO.
Cheers,
Tadej
--
Tadej Borovšak
tadeboro.blogspot.com
tadeboro gmail com
tadej borovsak gmail com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]