GNOME Bugzilla – Bug 93629
expander animation doesn't always finish (bottom of the bug)
Last modified: 2011-02-04 16:11:56 UTC
I have a GtkTreeStore where elements are changed after insertion. If I assign the model as a child of GtkTreeModelSort, and sort on a column that changes, it results in unpredictable behaviour and several warnings: Gtk-CRITICAL **: file gtktreeview.c: line 3845 (validate_visible_area): assertion `has_next' 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. Gtk-CRITICAL **: file gtktreestore.c: line 619 (gtk_tree_store_get_value): assertion `iter->stamp == GTK_TREE_STORE (tree_model)->stamp' failed Gtk-CRITICAL **: file gtktreemodelsort.c: line 1171 (gtk_tree_model_sort_real_unref_node): assertion `elt->ref_count > 0' failed The last warning is also produced if the child is a GtkListStore. * Steps to provoke this: Compile the attached source file with cc `pkg-config --cflags --libs gtk+-2.0` -o gtk2-bug gtk2-bug.c and run it. Sort on the column named "Sort Me". Expand some nodes and click on their children. The test case is based on a test attached to another (slightly confused IMHO) bug report. * Background: I'm using GtkTreeStore and GtkListStore in the test case - the model I actually want to use with GtkTreeModelSort is my own, and I didn't want my own bugs to interfere with the test. However, this means I would have to implement a sortable interface to that model and do the sorting myself to work around this bug, which is hard, since the data nodes are not owned by my GtkTreeModel, but a lower layer that does not depend on GTK. In practice it would be another GtkTreeModelSort-alike implementation. * Free ice cream for whoever fixes this. I'm not familiar enough with the source myself, and it warns me of dangers to my pets.
Created attachment 11169 [details] Test case that should readily provoke the bug.
Oh man what a bug (: It took a while to find out what's wrong. I think the attached patch fixes the problem. Could you verify if this patch really fixes the problem (just to be sure)? If so I can get it into gtk+ cvs ASAP. (the patch is against gtk+ HEAD, but I think it will apply cleanly to 2-0 too).
Created attachment 11370 [details] [review] possible fix
Works perfectly for me. Thanks! I'd like to mention a side effect, though. I don't think this is a bug in GtkTreeModelSort - it could be in GtkTreeView itself: When I click an expander, and the item moves before expanding fully, it gets frozen in the state it was in when moved. This means that the expander will be forever drawn at a bad rotation angle, and that if the child items were not shown before the reorder occurred, they won't be shown at all. The test program is the same. I'm attaching two test images to show these cases. It's not a critical bug to me, so do whatever you like with it - change the bug if it's in another component etc.
Created attachment 11388 [details] Bad expander
Created attachment 11389 [details] Bad expander, children not shown
committed the modelsort fix on HEAD. Will prolly commit it on stable too later on. Not sure yet how to fix your second bug.
Moving remaining bugs to 2.2.1.
Fixed the bad expander issue on HEAD, gtk-2-2.