# fxRuby: changing icon in TreeItem crashes

**URL:** <https://www.ruby-forum.com/t/fxruby-changing-icon-in-treeitem-crashes/57076>\
**Category:** Ruby\
**Created:** [April 7, 2006, 12:44am UTC](https://www.ruby-forum.com/t/fxruby-changing-icon-in-treeitem-crashes/57076 "2006-04-07T00:44:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![christer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a5b964/32.png) [@christer](https://www.ruby-forum.com/u/christer)\
**Post date:** [April 7, 2006, 12:44am UTC](https://www.ruby-forum.com/t/fxruby-changing-icon-in-treeitem-crashes/57076/1 "2006-04-07T00:44:05Z")

</div>

I would like to change the icon used by TreeItem in TreeList.  
I’m using

# Convenience function to load & construct an icon

def makeIcon(filename)  
begin  
filename = File.join(“icons”, filename)  
icon = nil  
File.open(filename, “rb”) { |f|  
icon = FXPNGIcon.new(getApp(), f.read)  
}  
icon  
rescue  
raise RuntimeError, “Couldn’t load icon: #{filename}”  
end  
end

…

doc = makeIcon(“minidoc.png”)  
@tree.currentItem.text = “new icon coming …”  
@tree.currentItem.closedIcon = doc # crash!

I had no problem adding icons when the TreeItem was constructed.

I’m using fox14.

Christer
