Re: treeview: seg fault When Collapsing a Row Containg a Selected Item

2007-06-18 Thread James Scott Jr
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


Re: treeview: seg fault When Collapsing a Row Containg a Selected Item

2007-06-18 Thread Marshall Lake

 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

 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!

That's the ticket!  I appreciate your help.

-- 
Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


treeview: seg fault When Collapsing a Row Containg a Selected Item

2007-06-16 Thread Marshall Lake

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

The treeview works fine if the user never collapses the row and goes on to 
make another selection, either in that same top-level or a different 
top-level.  Also, if a row is expanded and then collapsed with no child 
being selected it works fine.

As an aside (?), I tried gtk_tree_selection_unselect_iter() on the child 
after it was selected and got a seg fault and the same error as noted 
above at the point the gtk_tree_selection_unselect_iter() was executed.

Can someone tell me what might need to be done to avoid the seg fault?

-- 
Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: treeview: seg fault When Collapsing a Row Containg a Selected Item

2007-06-16 Thread James Scott Jr

On Sat, 2007-06-16 at 12:15 -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)

never trust an iter...

James,


 The treeview works fine if the user never collapses the row and goes on to 
 make another selection, either in that same top-level or a different 
 top-level.  Also, if a row is expanded and then collapsed with no child 
 being selected it works fine.
 
 As an aside (?), I tried gtk_tree_selection_unselect_iter() on the child 
 after it was selected and got a seg fault and the same error as noted 
 above at the point the gtk_tree_selection_unselect_iter() was executed.
 
 Can someone tell me what might need to be done to avoid the seg fault?
 
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list