Meinrad Recheis
2006-Apr-07 08:22 UTC
[fxruby-users] Fwd: fxRuby: changing icon in TreeItem crashes
lyle, 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> 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.> -----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")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. > > ChristerYura.
Lyle Johnson
2006-Apr-07 12:56 UTC
[fxruby-users] Fwd: fxRuby: changing icon in TreeItem crashes
On Apr 7, 2006, at 3:22 AM, Meinrad Recheis wrote:> 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.I''ve added a feature request about this but it''s going to be difficult or impossible to do without significant changes to the C++ FOX library. There are numerous places in the C++ code where Jeroen checks to see if an icon has been created, and if it hasn''t, he calls the fxerror() function. The fxerror() function prints out an error message (e.g. "Illegal icon specified") and then calls the system''s abort() function. Various people have asked for him to change this mechanism to make it more flexible. For example, one approach would be to provide a C++ API to set an error handler function in place of fxerror(), and let FOX call that function instead. Another obvious one is to have FOX throw C++ exceptions instead of calling fxerror(). So far Jeroen has chosen to leave things the way they are.
Dylan Bruzenak
2006-Apr-07 15:28 UTC
[fxruby-users] Fwd: fxRuby: changing icon in TreeItem crashes -segfault question
What about the segfaults ? I am assuming that is why I get the ''application asked to be terminated in an unusual way'' errors.> On Apr 7, 2006, at 3:22 AM, Meinrad Recheis wrote: > > >> 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. >> > > I''ve added a feature request about this but it''s going to be difficult > or impossible to do without significant changes to the C++ FOX library. > There are numerous places in the C++ code where Jeroen checks to see if > an icon has been created, and if it hasn''t, he calls the fxerror() > function. The fxerror() function prints out an error message (e.g. > "Illegal icon specified") and then calls the system''s abort() function. > > Various people have asked for him to change this mechanism to make it > more flexible. For example, one approach would be to provide a C++ API > to set an error handler function in place of fxerror(), and let FOX > call that function instead. Another obvious one is to have FOX throw > C++ exceptions instead of calling fxerror(). So far Jeroen has chosen > to leave things the way they are. > > _______________________________________________ > fxruby-users mailing list > fxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/fxruby-users > >
lyle at knology.net
2006-Apr-07 21:15 UTC
[fxruby-users] Fwd: fxRuby: changing icon in TreeItem crashes
On Fri, 7 Apr 2006 22:23:40 +0200, "Meinrad Recheis" <meinrad.recheis at gmail.com> wrote :> hmm. are you sure that there is no solution that does not require > changing the c++ code?I am sure that there is no solution that doesn''t require changing a lot of someone''s C++ code, either Jeroen''s or mine. ;)> how about wrapping every method that accepts an icon? the wrapping > code check''s if icon.created? and proceeds else raises an exception.It''s not always an error to pass a non-created icon to a method that accepts an icon. But I see what you''re getting at and that might be a solution that doesn''t involve changes to FOX itself.