On Sun, 2007-06-17 at 09:37 -0400, Marshall Lake wrote: > >> I have a treeview/treestore containing many top-level rows. Each > >> top-level row contains many children. The treeview works fine except > >> for one thing. If the user expands a top-level row, selects a child, > >> and then collapses that row the program seg faults with the console > >> error: > >> > >> gtk_tree_store_get_value: assertion `iter->stamp == GTK_TREE_STORE > >> (tree_model)->stamp' failed > >> gtype.c:3351: type id `0' is invalid > >> can't peek value table for type `<invalid>' which is not currently > >> referenced > > > Without seeing the code I can only guess. I seems that the iter your > > using is invalid -- or no longer valid. This could occur if you used a > > LOCAL variable to create the iter; then saved the pointer of that inter > > and tried to use it somewhere else which creates the segfault. > > > > To poke around looking for it, use this api to test iters before use: > > bool=gtk_tree_store_iter_is_valid(GtkTreeStore *tree_model, GtkTreeIter > > *iter) > > I apologize for not posting the code originally. See below. > > I don't quite understand how the gtk_tree_store_iter_is_valid() function > will help me since the seg fault occurs when the top-level row is > collapsed and is (seemingly ?) out of my control. > > > > void > TeamSelected2 (GtkTreeSelection *selection) { > GtkTreeModel *model; > GtkTreePath *path; > GtkTreeIter iter; > gint sub, row_count, x; > gchar *teamname, path_str[10] = " "; > gboolean valid; > > gtk_tree_selection_get_selected (selection, &model, &iter);
The gtk_tree_selection_get_selected() api returns TRUE is something is selected. You never checked its return value! consider doing this: if (selection == NULL) { return; } if ( !( gtk_tree_selection_get_selected (selection, &model, &iter) ) ) { return; } > gtk_tree_model_get (model, &iter, NAME_COLUMN, &teamname, -1); > > if (strlen (teamname) == 4) > /* user clicked on a year */ > return; > Not sure what your looking for here? you already have the iter to the selected row? > > for (sub = row_count = 0; sub < toplevelentries; sub++, row_count = 0) { > /* walk through the root level of data (years) */ > sprintf (&path_str[0], "%d:0", sub); > path = gtk_tree_path_new_from_string (&path_str[0]); > > valid = gtk_tree_model_get_iter (model, &iter, path); > while (valid) { > /* walk through the sub-level (teams), looking for the selected > row */ > if (gtk_tree_selection_iter_is_selected (selection, &iter) == > TRUE) > /* get out of the for() loop */ > goto GetOutFor; > > row_count++; > valid = gtk_tree_model_iter_next (model, &iter); > } > } > GetOutFor: > > [do some processing and return] > _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list