Re: Do TreeIters persist after foreach search ?



Emmanuele Bassi wrote:
On Thu, 2007-11-08 at 11:53 +0000, Dave Howorth wrote:

Any ideas what's happening, or better ways to find a node in the model?

use a Gtk2::TreePath instead, which is meant to keep pointing to a row
in the model (regardless of the fact if that row exists or if the data
has been changed):

  # inside the foreach():
  $match_path = $model->get_path($iter);

the sub is already given the path as an arg so that can be simplified:

    $match_path = $path;

and then:

  $iter = $model->get_iter($match_path); # always check retval

I was trying to avoid this because I think it must do a second tree walk
to reach the node? Which shouldn't be necessary.

But I've switched to this technique at the moment unless anybody can
suggest anything better.

At the moment the search is way too slow. I'm just about to profile it
to see whether I can fix it or whether I need to do my main tree
handling outside of the gtk tree model and just use the gtk model as a
display slave.

I guess another alternative might be to reimplement foreach's tree walk
myself which would lose the function call overhead and will probably
avoid whatever weirdness is messing with the stamp.

Thanks, Dave



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