Help removing GtkListStore rows

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

 



I'm porting an app I wrote from gtk 1.2 to grk 2.2. I have to convert
old GtkCList to GtkListStore. I'm in throuble removing rows from the
list. In the app, when the user hits a button it removes the currently
selected row.
Here is the function connected to the button:


static void
rem_item ()
{
  Files *tmp;
  gint row;
  GtkTreeSelection *selection;
  GtkTreeModel *model;
  GtkTreeIter iter;
  GtkTreePath *path;

  /* First of all detects the row selected and the model */
  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW
	(main_list_store));
  g_return_if_fail (gtk_tree_selection_get_selected
		    (selection, &model, &iter));
  g_assert (model != NULL);

  /* Let's retrive the current row index */
  /* I need this for internal software functions */
  path = gtk_tree_model_get_path (model, &iter);
  row = atoi (gtk_tree_path_to_string (path)); 
#if DEBUG
  g_print ("I'm going to delete row %d... ", row);
#endif
  gtk_tree_path_free (path);

  /* Then deletes the element from the files list */
  /* This is internal */
  tmp = del_file (fileslist, row);
  fileslist = tmp;


  /* Removes the entry from the list and control the selection */
  if (gtk_list_store_remove (GTK_LIST_STORE (model), &iter))
    gtk_tree_selection_select_iter (selection, &iter);
}

But when i call theis function, the program goes in segmentation fault
without any message. 
It doesn'n that on every row I delete, but I cannot reproduce a
significant behaviour. Simply sometimes in does and sometimes it doesn't
for example mybe it deletes well the first row but crashes on the
second. I think it depends on something in the iter reference, but I
dont know. If I debug, the seg fault happens when it returns from the
function. 

If you need the functions where the list store is constructed and the
one where it is filled let me know.

Please help me!
Bye
Davide
-- 
LordGolem <lordgolem@xxxxxxxxxxxxxxxxx>

_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux