# Cannot modify selected\_each model

**URL:** <https://www.ruby-forum.com/t/cannot-modify-selected-each-model/109342>\
**Category:** Ruby-Gnome 2\
**Created:** [July 13, 2007, 4:33pm UTC](https://www.ruby-forum.com/t/cannot-modify-selected-each-model/109342 "2007-07-13T16:33:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mack\_stout](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a3d4f5/32.png) [@mack\_stout](https://www.ruby-forum.com/u/mack_stout)\
**Post date:** [July 13, 2007, 4:33pm UTC](https://www.ruby-forum.com/t/cannot-modify-selected-each-model/109342/1 "2007-07-13T16:33:46Z")

</div>

Hi List,

I’m having some trouble w/ this piece of code:

@stores\_selected.selected\_each do |model, path, iter|  
subrow = model.append(iter)  
end

it appears as though modifying the model from within a selected\_each  
iteration is not allowed as I get this error:

Gtk-WARNING \*\*:The model has been modified from within  
gtk\_tree\_selection\_selected\_foreach.  
This function is for observing the selections of the tree only. If you  
are  
trying to get all selected items from the tree, try using  
gtk\_tree\_selection\_get\_selected\_rows instead.

I don’t see a method for get\_selected\_rows in the api, is there  
something  
I’m doing wrong?

Max

---

<div class="post-metadata">

**Author:** ![mack\_stout](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a3d4f5/32.png) [@mack\_stout](https://www.ruby-forum.com/u/mack_stout)\
**Post date:** [July 13, 2007, 5:46pm UTC](https://www.ruby-forum.com/t/cannot-modify-selected-each-model/109342/2 "2007-07-13T17:46:56Z")

</div>

Hi,

On Fri, 13 Jul 2007 09:33:09 -0500  
“mack stout” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Gtk-WARNING \*\*:The model has been modified from within  
> gtk\_tree\_selection\_selected\_foreach.  
> This function is for observing the selections of the tree only. If you are  
> trying to get all selected items from the tree, try using  
> gtk\_tree\_selection\_get\_selected\_rows instead.
> 
> I don’t see a method for get\_selected\_rows in the api, is there something  
> I’m doing wrong?

Gtk::TreeSelection#selected\_rows

–  
.:% Masao M.[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

* * *

This [SF.net](http://SF.net) email is sponsored by DB2 Express  
Download DB2 Express C - the FREE version of DB2 express and take  
control of your XML. No limits. Just data. Click to get it now.  
[http://sourceforge.net/powerbar/db2/](http://sourceforge.net/powerbar/db2/)
