That fscking bug in TnyGtkHeaderListModel



Is fixed: The bug about ghost rows.

This was the problem: The GtkTreeModel implementations checked for
me->items->len as largest length, not me->cur_len. Among them some have
to return FALSE if the requested item is > the final length.

The me->cur_len is the "registered" length: the amount of times a
gtk_tree_model_row_inserted was called or the 'length that the Gtk+
system should at this exact moment consider'. me->items->len is the true
length or 'the length of the TnyList implementation': the amount of
items that *are* *in* the instance at this exact moment.

The difference is that me->cur_len is what happened on the mainloop,
me->items->len is "right now. at this exact moment, not considering the
mainloop": me->cur_len will "in the mainloop" eventually become
me->items->len, but might be less at a specific moment in time.

The assertion warning of a few weeks ago was caused by the sort model.

For that assertion warning I had set me->cur_len to the initial value of
one. This was the bug because that made the GtkTreeView believe that it
had already seen the first row, yet I was gtk_tree_model_row_inserted it
again (so it showed the first row as a ghost row and as its actual row).

It gave an assertion because the sort model did get a first iter
(because one of the methods that implement GtkTreeModel didn't return
FALSE because it checked for me->items->len for the length in stead of
me->cur_len): only me->cur_len is what GtkTreeWhateverThings know about
because only *that* length got already signalled to them (at a specific
moment in time).


This was the assertion in Gtk+:

static void
gtk_tree_model_sort_build_level (GtkTreeModelSort *tree_model_sort,
				 SortLevel        *parent_level,
				 SortElt          *parent_elt)
{

 ...
    if (gtk_tree_model_get_iter_first (tree_model_sort->child_model, &iter) == FALSE)
	return;
    length = gtk_tree_model_iter_n_children (tree_model_sort->child_model, NULL);

 ...
 -> g_return_if_fail (length > 0); <-

The developer was right: gtk_tree_model_get_iter_first should have
returned FALSE if the model's length is 0. At that time, though,
me->items->len was already at 1, yet me->cur_len or the amount of
row_inserted calls that happened, was still at 0.


Lot's of bla bla bla, for a small fix :-)


-- 
Philip Van Hoof, software developer
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
http://www.pvanhoof.be/blog







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