]> Pileus Git - ~andy/gtk/commit
bgo#687196 - Fix model corruption during file removal
authorFederico Mena Quintero <federico@gnome.org>
Thu, 1 Nov 2012 23:48:23 +0000 (17:48 -0600)
committerFederico Mena Quintero <federico@gnome.org>
Fri, 2 Nov 2012 20:09:01 +0000 (14:09 -0600)
commitea3a750f1305acc838beefacbd41ee77a6835261
treee1e98cd68eb1c11bb34b038a7e2be19bba275507
parent94e3d7faf1d77f412aa872fd957c16218e2731c2
bgo#687196 - Fix model corruption during file removal

The main problem is that we were emitting the row-deleted signal for the model in the middle
of the process that actually deletes the row from the model (remove the row from the array,
update the model->file_lookup hash table, etc.).  In the model's caller, one of the row-deleted
callbacks was requesting an iter, which caused the model to revalidate itself - but it did
this while it was in an inconsistent state.  This led to an assertion failure later when the
model resorted itself.

The fix in remove_file() is like this:

* The filteredness/visibility of the deleted node is not updated.  The
  node will simply be gone; we don't need to update those values at
  all.

* We invalidate just the node that is being deleted.

* The model->file_lookup hash table is not completely nuked; instead,
  we carefully adjust its indices.

* The row-deleted signal is only emitted at the very end, when
  deletion is complete and the model is consistent.

Many thanks to William Hua for doing the detective work on this bug!

Signed-off-by: Federico Mena Quintero <federico@gnome.org>
gtk/gtkfilesystemmodel.c