3

I am building an app using Glade and Gtk.

I have a treeview. In Glade I configured this treeview so that its model would be a GtkListstore called liststore. This liststore has two columns of type gcharray.

I use pyinotify to detect when a usb media is plugged in and out. When something is plugged in, here is what happened :

self.liststore.append() # empty row
for value1 in some_list:
    row_shape = [value2,value1]
    self.liststore.append(row_shape)

Basically I just append a few rows to my liststore. This works fine.

When a USB media is plugged out, here is what is supposed to happen :

current_iter = self.liststore.get_iter_first()
delete_items = list()
while current_iter:
    if self.liststore[current_iter][0] == some_value
         delete_items.append(current_iter)
    current_iter = self.liststore.iter_next(current_iter)
for i in delete_items:
     self.liststore.remove(i)

When the code gets to the removing part, I get a black screen and an error saying :

Gtk-CRITICAL **: gtktreeview.c:6908 (do_validate_rows) : assertion `gtk_tree_model_iter_next (tree_view_>priv->model, &iter)' failed. There is a disparity between the internal view of the GtkTreeView and the GtkTreeModel. This generally means that the model has changed without letting the view know. Any display from now on is likely to be incorrect.

What is wrong in my deletion process?

EDIT :

I partly solved the problem by setting a new liststore when I want to erase the first one. My screen does not go black anymor but I still get an error :

Gtk-CRITICAL **: gtk_list_store_get_value: assertion 'column < priv->n_columns' failed

M.Brbr
  • 83
  • 7

0 Answers0