Re: signals versus vfuncs
- From: Tim Janik <timj gtk org>
- To: muppet <scott asofyet org>
- Cc: Gtk+ Developers <gtk-devel-list gnome org>
- Subject: Re: signals versus vfuncs
- Date: Sat, 10 Jan 2004 18:59:17 +0100 (CET)
On Fri, 9 Jan 2004, muppet wrote:
>
> Christof Petig said:
> > Iterators usually contain pointers to internal data structures, Paths
> > are just an ordinal representation of a (potential) node position.
> > Prepare to accept zero'd iterators (I sometimes get some from
> > GtkTreeView after changing between models).
[...]
> is there any way at all to get notification when an iter is no longer in use?
> perhaps there's something simple i'm missing...
there's no way to know when an iterator is being freed or copied since
they are pure value objects. but that's not a real problem, because
an iterator basically "refers to a certain state of a model", rather than
maintains its own state (which would require notification/hooks).
if you implement your own model and need to deal with life-time issues
and iterators, you basically do:
setup_model() {
model->stamp = 1;
model->glue_object = new_glue_object();
}
modify_model() {
model->stamp++; /* "invalidates" all iterators with old stamp */
destroy_glue_object (model->glue_object);
model->glue_object = new_glue_object();
}
fill_iter() {
iter->stamp = model->stamp;
iter->data1 = model->glue_object; /* valid as long as stamp is valid */
iter->data2 = ...; /* valid as long as data1 is valid */
}
use_iter() {
g_return_if_fail (iter->stamp == model->stamp);
/* since iter->stamp is valid, iter->data1 is also valid */
use_glue_object (iter->data1, iter->data2);
}
>
> --
> muppet <scott at asofyet dot org>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]