fxRuby: changing icon in TreeItem crashes

Christer,

You have to explicitly call "create" for the new icon to
create the server side object. Fox does it automatically
for all the objects it can see at the time "create" is
called for the FXApp object if I remember correctly.

From: list-bounce@example.com
[mailto:list-bounce@example.com] On Behalf Of Christer Nilsson
Sent: Thursday, April 06, 2006 6:44 PM

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")

    doc.create

  @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

Yura.

···

-----Original Message-----

Thanks Yura, this solved my problem!

Do I have to destroy or delete also, to balance create?

Christer

Kloubakov Yura wrote:

···

Christer,

You have to explicitly call "create" for the new icon to
create the server side object. Fox does it automatically
for all the objects it can see at the time "create" is
called for the FXApp object if I remember correctly.

    begin

...

  doc = makeIcon("minidoc.png")

    doc.create

  @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

Yura.

--
Posted via http://www.ruby-forum.com/\.

No, the icon's resources will be destroyed automatically when it's
garbage-collected.

···

On 4/7/06, Christer Nilsson <janchrister.nilsson@gmail.com> wrote:

Do I have to destroy or delete also, to balance create?