Re: GtkListStore and Threads problems
- From: Peter Bloomfield <peterbloomfield bellsouth net>
- To: Lorena Salinas <lsalinas invap com ar>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: GtkListStore and Threads problems
- Date: Wed, 15 Jun 2005 16:45:32 +0000
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
(my_model),
&iter);
while (valid) {
gtk_tree_model_get (GTK_TREE_MODEL (my_model), &iter,
MYMODEL_COL_STATUS, &status,
-1);
/* do some long calculations.... */
gdk_threads_enter(); /* get GTK thread lock */
gtk_list_store_set (GTK_LIST_STORE (my_model), &iter,
MYMODEL_COL_STATUS,STATUS_NORMAL,
-1);
gdk_threads_leave(); /* release GTK thread lock */
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (my_model),
&iter);
}
This is the only place where I update the model...
Is it valid to assume that iter is the same, that it hasn't
changed?
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.
Peter
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]