sizer = BoxSizer.new(VERTICAL)
sizer.add(@grid, 1, GROW|ALL, 2)
panel.set_sizer(sizer)
evt_grid_cell_change do |evt|
row = evt.get_row
@grid.insert_rows(row, 1)
end
frame.show(TRUE)
end
end
TestApp.new.main_loop
The intent is to add a new row when one enters data in the last empty
row,
but when data is entered into a cell in the last row, the program
crashes:
C:/Ruby/lib/ruby/gems/1.8/gems/wxruby-2.0.1-x86-mswin32-60/lib/wx/classes/grid.rb:105:in process_event': stack level too deep (SystemStackError) from C:/Ruby/lib/ruby/gems/1.8/gems/wxruby-2.0.1-x86-mswin32-60/lib/wx/classes/grid.rb:105:in__insert_rows’
from
C:/Ruby/lib/ruby/gems/1.8/gems/wxruby-2.0.1-x86-mswin32-60/lib/wx/classes/grid.rb:105:in insert_rows' from x.rb:19:inon_init’
from
C:/Ruby/lib/ruby/gems/1.8/gems/wxruby-2.0.1-x86-mswin32-60/lib/wx/classes/grid.rb:105:in call' from C:/Ruby/lib/ruby/gems/1.8/gems/wxruby-2.0.1-x86-mswin32-60/lib/wx/classes/grid.rb:105:inprocess_event’
from
C:/Ruby/lib/ruby/gems/1.8/gems/wxruby-2.0.1-x86-mswin32-60/lib/wx/classes/grid.rb:105:in __insert_rows' from C:/Ruby/lib/ruby/gems/1.8/gems/wxruby-2.0.1-x86-mswin32-60/lib/wx/classes/grid.rb:105:ininsert_rows’
from x.rb:19:in on_init' ... 18546 levels... from x.rb:26:inprocess_event’
from x.rb:26:in on_run' from x.rb:26:inmain_loop’
from x.rb:26
It looks like insert_rows is getting invoked recursively. The same
program
works fine under FreeBSD, but I think I have an older (pre-wxruby2)
version
installed.
def on_init
row = evt.get_row
The intent is to add a new row when one enters data in the last empty row,
from x.rb:19:in on_init' ... 18546 levels... from x.rb:26:in process_event’
from x.rb:26:in on_run' from x.rb:26:in main_loop’
from x.rb:26
It looks like insert_rows is getting invoked recursively. The same program
works fine under FreeBSD, but I think I have an older (pre-wxruby2) version
installed.
I’d say that inserting a row causes a EVT_GRID_CELL_CHANGE event,
effectively calling your event handler again, which in turn issues a new
EVT_GRID_CELL_CHANGE, causing your event handler to be triggered once
again, causing… ad infinitum.
You may be able to prevent this by setting an instance variable and
checking it’s value before trying to insert a row.
Vale,
Marvin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
It looks like insert_rows is getting invoked recursively. The same program
works fine under FreeBSD, but I think I have an older (pre-wxruby2) version
installed.
Yes, but I’m not sure why it should. IOW this looks to me like a bug in
wxruby, especially since this didn’t happen on the older wxruby. (I’m
assuming the operative difference is between wxruby v1 vs. v2 rather
than
FreeBSD vs. Windows.)
I’d say that inserting a row causes a EVT_GRID_CELL_CHANGE event,
effectively calling your event handler again, which in turn issues a new
EVT_GRID_CELL_CHANGE, causing your event handler to be triggered once
again, causing… ad infinitum.
You may be able to prevent this by setting an instance variable and
checking it’s value before trying to insert a row.
Good suggestion - I’ll look into doing that. Gratias ago.
require ‘wx’
sizer = BoxSizer.new(VERTICAL)
end
from x.rb:19:in `on_init’
It looks like insert_rows is getting invoked recursively. The same program
works fine under FreeBSD, but I think I have an older (pre-wxruby2) version
installed.
Yes, but I’m not sure why it should. IOW this looks to me like a bug in
wxruby, especially since this didn’t happen on the older wxruby. (I’m
assuming the operative difference is between wxruby v1 vs. v2 rather than
FreeBSD vs. Windows.)
wxRuby (or at least wxWidgets) sometimes behaves a little different on
Windows, especially regarding events. The most recent case I experienced
was a TreeCtrl getting an EVT_SELECTION_CHANGED event during application
startup, which it doesn’t get on Linux. Both systems used wxRuby 2.0.1.
I’d say that inserting a row causes a EVT_GRID_CELL_CHANGE event,
effectively calling your event handler again, which in turn issues a new
EVT_GRID_CELL_CHANGE, causing your event handler to be triggered once
again, causing… ad infinitum.
You may be able to prevent this by setting an instance variable and
checking it’s value before trying to insert a row.
Good suggestion - I’ll look into doing that. Gratias ago.
Adiuvare mihi gaudium est.
Vale,
Marvin
Et valeas tu.
Si vales, bene est, ego quidem valeo. (I think it was the younger Pliny
always shortening this to SVBEEQV).
But the times I was used to Latin are gone now, hopefully the few
phrases above are gramicatically correct
Nevertheless I like Latin for being able to understand some phrases in
Spanish, Italian or even English I’ve never encountered before (I’m from
Germany). And, of course, being able to read (at least with a bit of
efford of reactivating old knowledge) these really old texts is just
cool.
Vale,
Marvin alias Quintus
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/