[fxruby-users] Fwd: fxRuby: changing icon in TreeItem crashes

Meinrad Recheis meinrad.recheis at gmail.com
Fri Apr 7 04:22:09 EDT 2006

this is a common pitfall! (see below msg to ruby-talk). since you
asked for ideas for the new fxruby api here is a new one: icons should
maintain a @created state and don't crash but either raise an
Exception or just call create in such a case.
same with fxfonts.
also segfaulting constructors that got nil references to their parent
are troublesome.

just some suggestions,
-- henon

---------- Forwarded message ----------
From: Kloubakov Yura <YKloubakov at ftxs.fujitsu.com>
Date: Apr 7, 2006 10:14 AM
Subject: Re: fxRuby: changing icon in TreeItem crashes
To: ruby-talk ML <ruby-talk at ruby-lang.org>


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.

> -----Original Message-----
> From: list-bounce at example.com
> [mailto:list-bounce at 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")


>   @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


More information about the fxruby-users mailing list