Re: gtk.TreeModel.iter_children() method, how often should it be called?



Did some more  checking and inserted some debugging statements, I found that:

on_iter_next is called 23808 times after updating one line in my
43-element tree.  That''s almost twenty-four thousand times!  I'm
going to try to find a way to implement your idea but I'd really like
to know:

What makes TreeView stop calling iter_next and wait for the next event?

As I mentioned previously, the first time my 50-element tree is
displayed, I get a call for each line in the tree as expected. After
updating just one of those lines,  I get almost 24000 calls.

I just don't understand enough to know where to look for the trouble,
hence the question.

On Mon, Jun 22, 2009 at 3:58 PM, Tadej Borovšak<tadeboro gmail com> wrote:
> Hi.
>
>> 1. Is this normal (I hope not!) behavior?
>
> I'm not sure about 1000, but calling this function a lot is normal if
> you make major changes to your model while attached to GtkTreeView.
>
>> 2. What tells the TreeModel to stop calling
>> gtk.TreeModel.iter_children()?  How does the TM know that it has done
>> everything it needs to do before displaying the tree?
>
> Try detaching model from tree view before doing any major change.
> Sample code would look something like this (in C):
> ------------ CODE -----------
> model = gtk_tree_view_get_model( GTK_TREE_VIEW( tree ) );
> g_object_ref( G_OBJECT( model ) );
> gtk_tree_view_set_model( GTK_TREE_VIEW( tree ), NULL );
>
> /* Make changes */
>
> gtk_tree_view_set_model( GTK_TREE_VIEW( tree ), model );
> g_object_unref( G_OBJECT( model ) );
> ------------ /CODE -------------
>
> Hope this helps.
>
> --
> Tadej Borovšak
> tadeboro.blogspot.com
> tadeboro gmail com
> tadej borovsak gmail com
>



-- 
Gerald Britton


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