Re: Problems Re-populating GtkTreeView



On Sun, Aug 12, 2007 at 03:16:45PM -0400, Andrew Rowland wrote:
I've been working at this for several days now and I'm hoping someone
can guide me down the right path (although I'm not opposed to just being
given the answer).  Let me say TIA now and I apologize if I've included
too much code, error messages, etc.

You are the first after a long time who bothered to use
a debugger himself before posting to the list and included
the actual code, the actual error messages and noted the
place where it crashes (sort of) in the post.

This is not a reason for an apology, but for opening
a bottle of champagne...

BTW, ever heard of libgda/gnome-db?

...

The following is thrown in the terminal.

(reliafree:32523): Gtk-CRITICAL **: gtk_tree_model_get_iter: assertion
`GTK_IS_TREE_MODEL (tree_model)' failed
...

Evidently, the tree model does not exist any more here (the
other likely possibility would be passing a wrong
pointer as the model, but I just happen to know).  And
that's because here

    g_object_unref( part_model );

you release your reference to it.  The only remaining
reference is that owned by the treeview, which is released
when the treeview is closed (destroyed) and then the model
goes poof because it is not used by anything (more
precisely, nothing claims any use of it -- you still think
you use it, but since you do not own any reference, nothing
knows you want to use it).

Keep your reference until you are done with the model (and
don't release references more times than you took them).
Unreferencing the model immediately after
gtk_tree_view_set_model() is convenient when you want the
model to be destroyed together with the view and/or when
a different model is set -- but that's the opposite of what
you want.

Also, clearing the model and filling it with something
completely different will not save much.  Creating a new
model, filling it, calling gtk_tree_view_set_model() and
unreferencing the new model can be even more efficient.

Yeti

--
http://gwyddion.net/



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