[fxruby-users] Big tables still segfault with fxruby-1.2.4
Joel VanderWerf
vjoel at PATH.Berkeley.EDU
Fri Feb 25 13:39:21 EST 2005
By putting some GC.start lines in David's original code, the problem
comes up much faster. With just 10 rows, it happens in 2 clicks on
button 1. Changes marked with " # <--- added".
$ ruby fxbug2.rb
fxbug2.rb:25: [BUG] rb_gc_mark(): unknown data type 0x30(0x82255f0) non
object
ruby 1.8.2 (2004-12-25) [i686-linux]
zsh: abort ruby fxbug2.rb
Another observation: moving the setTableSize call into initialize seems
to avoid the problem. So it appears that as long as you never discard
any items, it's ok. I may be able to use that in my own case...
------------------------
require "fox12"
include Fox
#GC.disable
class TestWindow < FXMainWindow
TABLE_SIZE = 10 # <--- added
def initialize(app)
super(app, "MyTest", nil, nil, DECOR_ALL, 0, 0, 600, 400, 0, 0)
mainFrame = FXVerticalFrame.new(self, LAYOUT_FILL_X|LAYOUT_FILL_Y)
@table = FXTable.new(mainFrame, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y)
goButton = FXButton.new(mainFrame, " Go method 1")
goButton.connect(SEL_COMMAND) { fillTable }
goButton2 = FXButton.new(mainFrame, " Go method 2")
goButton2.connect(SEL_COMMAND) { fillTable2 }
end
# fails after 2 to 15-20 iterations
def fillTable
@table.setTableSize(TABLE_SIZE, 1)
(0...TABLE_SIZE).each do |r|
@table.setItemText(r, 0, "#{r}")
GC.start # <--- added
end
@table.setFocus
GC.start # <--- added
end
# seems to require more iterations, but still fails
def fillTable2
@table.setTableSize(0, 1)
(0...TABLE_SIZE).each do |r|
@table.insertRows(r)
@table.setItemText(r, 0, "#{r}")
end
@table.setFocus
end
def create
super
show(PLACEMENT_SCREEN)
end
end
def runme
application = FXApp.new("MyTest", "FoxTest")
TestWindow.new(application)
application.create
application.run
end
runme
More information about the fxruby-users
mailing list