ruby-****@sourc*****
ruby-****@sourc*****
2012年 9月 28日 (金) 08:56:23 JST
------------------------- REMOTE_ADDR = 184.145.80.187 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-rr ------------------------- @@ -191,7 +191,8 @@ While traversing a store with a Gtk::TreeModel#each loop, it can be dangerous to add or remove rows from the store. It is easy to to remove rows with either Gtk::ListStore#remove or Gtk::TreeStore#remove. The removed row will also be removed from the tree view as well. -As stated, removing rows in a loop can be a problem, however. Following is an example showing, how to avoid such a problem, namely, it is not possible to traverse a store with Gtk::TreeModel#each, check whether the given row should be removed and then simply remove it by calling one of the models' remove methods. This can not work, because when the model is changed from within the foreach loop, this invalidates tree iters in the each method, and causes unpredictable behaviour. + +As stated, removing rows in a loop can be a problem, however. Following is an example showing, how to avoid such a problem, namely, it is not possible to traverse a store with Gtk::TreeModel#each, to check whether the given row should be removed and then simply remove it by calling one of the models' remove methods. This will not work, because when the model is changed from within a 'foreach loop', this invalidates 'tree iters' in the each method, and causes unpredictable behaviour. In events like this Gtk::TreeRowReference will help us: