Re: GtkListStore and Threads problems

On 06/15/2005 10:11:53 AM Wed, Lorena Salinas wrote:
Here is part of the function...

valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL

while (valid) {

gtk_tree_model_get (GTK_TREE_MODEL (my_model), &iter,

/* do some long calculations.... */

gdk_threads_enter(); /* get GTK thread lock */

gtk_list_store_set (GTK_LIST_STORE (my_model), &iter,

gdk_threads_leave(); /* release GTK thread lock */

valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (my_model),


This is the only place where I update the model...
Is it valid to assume that iter is the same, that it hasn't

The iter shouldn't have changed, and if the model isn't changed the iter should still be valid. But your original errors were coming from gtk_sequence_* functions, which are called from gtk_list_store_iter_next() as well as (possibly) gtk_list_store_set(), and you call gtk_list_store_iter_next() without holding the lock.

You could organize the loop around a path instead of an iter, and then when you really need an iter:
- grab the lock;
- initialize the iter;
- use the iter to get or set;
- drop the lock;
and get on with those really long calculations.


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