Forum: Ruby fxRuby: changing icon in TreeItem crashes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Af95bdaf87958c40150b813e94381bfd?d=identicon&s=25 Christer Nilsson (christer)
on 2006-04-07 00:44
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
This topic is locked and can not be replied to.