|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Invalid GtkTreeIterI have a program that declares a number of GtkTreeIter's. Recently the
prepending to the parent iter broke. I found out that, in some cases, the stamp to the iter's are negative just after the iter is declared. This means the iter is invalid. The following test program does the same thing. Why aren't all the stamps to the four iter's (a, b, c, and d) valid and positive? /* Test Program: tstIters.c * Build Command: * gcc -Wall -g2 `pkg-config --cflags gtk+-2.0` `pkg-config --libs gtk+-2.0` tstIters.c -o tstIters */ #include <stdio.h> #include <glib/gprintf.h> #include <gtk/gtk.h> int main(int argc, char **argv) { GtkTreeIter a; GtkTreeIter b; GtkTreeIter c; GtkTreeIter d; g_printf("a.stamp={%d}\n", a.stamp); g_printf("b.stamp={%d}\n", b.stamp); g_printf("c.stamp={%d}\n", c.stamp); g_printf("d.stamp={%d}\n", d.stamp); return 0; } Output $ ./tstIters a.stamp={4196240} b.stamp={496461664} c.stamp={-565527112} d.stamp={-565527128} $ ./tstIters a.stamp={4196240} b.stamp={-873273504} c.stamp={716436552} d.stamp={716436536} $ ./tstIters a.stamp={4196240} b.stamp={938256224} c.stamp={-1622865320} d.stamp={-1622865336} $ ./tstIters a.stamp={4196240} b.stamp={1835186016} c.stamp={-524655784} d.stamp={-524655800} $ Thanks, dhk _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@... http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list |
|
|
Re: Invalid GtkTreeIterEl mar, 03-11-2009 a las 16:53 -0500, dhk escribió:
> I have a program that declares a number of GtkTreeIter's. Recently the > prepending to the parent iter broke. I found out that, in some cases, > the stamp to the iter's are negative just after the iter is declared. > This means the iter is invalid. The following test program does the > same thing. > > Why aren't all the stamps to the four iter's (a, b, c, and d) valid and > positive? Because your iters are not initialized at all... you are going the wrong way on the search for a solution to your initial problem. What do you mean by "prepending to the parent iter broke"? Claudio -- Claudio Saavedra <csaavedra@...> _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@... http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list |
|
|
Re: Invalid GtkTreeIterClaudio Saavedra wrote:
> El mar, 03-11-2009 a las 16:53 -0500, dhk escribió: >> I have a program that declares a number of GtkTreeIter's. Recently the >> prepending to the parent iter broke. I found out that, in some cases, >> the stamp to the iter's are negative just after the iter is declared. >> This means the iter is invalid. The following test program does the >> same thing. >> >> Why aren't all the stamps to the four iter's (a, b, c, and d) valid and >> positive? > > Because your iters are not initialized at all... you are going the wrong > way on the search for a solution to your initial problem. What do you > mean by "prepending to the parent iter broke"? > > Claudio > In the gtk-demo program has a block as follows in the Tree View/Tree Store example. This doesn't initialize the the child iter before using it in the gtk_tree_store_append(), but the stamp is valid. /* add children */ while (holiday->label) { GtkTreeIter child_iter; gtk_tree_store_append (model, &child_iter, &iter); gtk_tree_store_set (model, &child_iter, HOLIDAY_NAME_COLUMN, holiday->label, ALEX_COLUMN, holiday->alex, HAVOC_COLUMN, holiday->havoc, TIM_COLUMN, holiday->tim, OWEN_COLUMN, holiday->owen, DAVE_COLUMN, holiday->dave, VISIBLE_COLUMN, TRUE, WORLD_COLUMN, holiday->world_holiday, -1); holiday++; } _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@... http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list |
|
|
Re: Invalid GtkTreeIterOn Wed, Nov 4, 2009 at 12:42 PM, dhk <dhkuhl@...> wrote:
> In the gtk-demo program has a block as follows in the Tree View/Tree > Store example. This doesn't initialize the the child iter before using > it in the gtk_tree_store_append(), but the stamp is valid. Iterators are not valid until they have been touched by a GtkTreeModel method. This will set the stamp of the iterator to correspond to the current stamp of the model. If an iterator that has just been declared has the same stamp as the model, then that's just luck. In the block that you've pasted below, child_iter is invalid until gtk_tree_store_append() returns. gtk_tree_store_append() sets the stamp on the iterator and thus makes it valid. regards, -kris. > /* add children */ > while (holiday->label) > { > GtkTreeIter child_iter; > > gtk_tree_store_append (model, &child_iter, &iter); > gtk_tree_store_set (model, &child_iter, > HOLIDAY_NAME_COLUMN, holiday->label, > ALEX_COLUMN, holiday->alex, > HAVOC_COLUMN, holiday->havoc, > TIM_COLUMN, holiday->tim, > OWEN_COLUMN, holiday->owen, > DAVE_COLUMN, holiday->dave, > VISIBLE_COLUMN, TRUE, > WORLD_COLUMN, holiday->world_holiday, > -1); > > holiday++; > } gtk-app-devel-list mailing list gtk-app-devel-list@... http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list |
| Free embeddable forum powered by Nabble | Forum Help |