Forum: Ruby-Gnome 2 Problem with Gtk::TreeViewColumn, sorting, and adding records?

Posted by Eric C. (eric_c)
on 2012-03-16 07:12
Hi:

I worked for several hours today on a problem I'm having adding records
to a listview.model when its sorted.

I'm creating a model with a few columns including a String and and a
DateTime.  I want to be able to sort on the DateTime column, so I set
the sort_column_id on the column:

id = <number of DateTime col>

column.set_sort_func(id) { |iter1, iter2|  iter1[id] <=> iter2[id] }
column.sort_column_id = id

That works fine, and I can add records at this point.  However, I want
to have the list appear sorted on startup, so I add this line before any
records are added:

model.set_sort_column_id(id)

After, that statement is in place, I can't add records without getting
this error on this line:

row = model.append
row[0] = anything

it says, "can't convert nil to integer for the []= method."  Its
completely haywire inside Gtk.  I've verified that all the objects are
valid.

The problem only occurs for the DateTime column, In fact, I reset the
model.set_sort_column_id to a String column or a pixbuf just so I can
add records then switch back when I'm done.

Its clearly a problem only when the active sort_column_id is set on the
DateTime column.  I verified this because when I clicked on the String
col, then clicked to add records, it was fine.  But when I clicked on
the DateTime col--whoops!  So it doesn't matter how the active
sort_column_id is set.  But if its set to DateTime when you try to add
records, it causes the error.

Am I missing something?

Thanks all your help.

Eric
Posted by Vincent Carmona (vinc-mai)
on 2012-03-16 19:27
(Received via mailing list)
Hi

Could you provide minimal working code to test this behaviour/bug ?
Posted by Eric C. (eric_c)
on 2012-03-18 04:06
Sorry for the delay.  I tried that, but I couldn't reproduce it.  Just
getting the error takes many lines of code.  I will work on it later
when I have time.

Thanks,
Eric
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.