[Fxruby-users] FXTreeList: Core dump when exiting
Status: Inactive
Brought to you by:
lyle
|
From: Christian v. M. <chr...@pd...> - 2004-01-25 10:31:11
|
Hello!
On Mon, Jan 12, 2004 at 03:14:23PM +0100, Chris Mueffling wrote:
> As soon as I find some spare time I'll try to break this down into
> a smaller example.
Ok, did it. The problem seems to be the usage of 'addItemLast' to add an item.
If I use 'addItemFirst' instead, no problems.
Just execute the enclosed code and close the window =>
[...]table_test.rb:74: [BUG] Segmentation fault
ruby 1.8.1 (2003-12-25) [i686-linux-gnu]
------- snip snip snip ---------------------------------------------------------------
#!/usr/bin/env ruby
require "fox"
include Fox
class TestTreeWindow < FXMainWindow
class ProjectTreeItem < FXTreeItem
def initialize(name, id)
super(name)
@id = id
end
attr_reader :id
end # class ProjectTreeItem
def initialize(app)
super(app, "Tree Test", nil, nil, DECOR_ALL, 0, 0, 0, 0)
__build
end
def create
super
show(PLACEMENT_SCREEN)
end # def create
private
def __build
@treelist = FXTreeList.new(self, 0, nil, 0,
HSCROLLING_OFF|TREELIST_BROWSESELECT|TREELIST_SHOWS_LINES|TREELIST_SHOWS_BOXES|
TREELIST_ROOT_BOXES|LAYOUT_FILL_X|LAYOUT_FILL_Y)
populate_tree
end
##
# Fill tree with project names.
#
def populate_tree
@projects = [
{ :name => "Top 1", :id => 1, :children => [], },
{ :name => "Top 2", :id => 5, :children => [], }
]
@treelist.clearItems
@projects.each { |project|
populate_tree_rec(nil, project)
}
end
def populate_tree_rec(parent, project)
child = @treelist.addItemLast(parent,
ProjectTreeItem.new(project[:name], project[:id]))
project[:children].each { |subproject|
populate_tree_rec(child, subproject)
}
end
end
# Start the whole thing
if __FILE__ == $0
# Make application
application = FXApp.new("TestApp", "FoxTest")
# Make window
TestTreeWindow.new(application)
# Create app
application.create
# Run
application.run
end
--------- snip snip snip -------------------------------------------------------------
--
chris
|