Re: g_slist_foreach and g_list_foreach functions



On Mon, 25 Sep 2000, Darin Adler wrote:

> on 9/24/00 8:43 AM, Owen Taylor at otaylor redhat com wrote:
> 
> > (I would say that if you are planning to remove elements, then doing
> > g_list_foreach() and g_list_remove() is a poor way to do it. If you
> > don't simply write it as a loop, which I would tend to do, you really
> > want a g_list_remove_all_custom() which takes a predicate. I forget if
> > Maciej's suggested additions have anything like that.)
> 
> The issue comes up when you do g_list_foreach and call other code, which
> sometimes does a g_list_remove.

right, while calling out third party code from something that
relies on internal state being preserved (such as node or
node->next) isn't an inherently good idea, we try to at least
make it work for this specific iterator case.
the issue is much worse for signal emissions than for iterators
though, there you really have to make sure your widget's state
_is_ in a consistent state that accounts for arbitrary third
party calls, and also can't rely on your widgets state having
been preserved around the emission.
(sorry, couldn't resist to coin that once more, it's far too
oftern not taken into account)

> 
>     -- Darin
> 

---
ciaoTJ





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