Lyle Johnson
2007-Mar-11 12:08 UTC
[fxruby-users] I''m working on my graphics window for the ruby quiz
On 3/10/07, Raj Sahae <rajsahae at gmail.com> wrote:> And I have no idea how to get this canvas working. > I''ve been looking at the scribble.rb example and trying to work off that. > > This is my display method, I get a seg fault when I run the method. > > def display > FXDCWindow.new(@canvas) do |dc| > @torus.grid.each_with_index do |row, y| > row.each_with_index do |part, x| > if part == :vapor > dc.foreground = "blue" > dc.drawPoint(x, y) > elsif part == :vacuum > dc.foreground = "black" > dc.drawPoint(x, y) > elsif part == :ice > dc.foreground = "gray" > dc.drawPoint(x, y) > end > end > end > end > endI don''t see anything that is obviously wrong with it. It might help to see the problem in context, though (i.e. in a complete program).
Meinrad Recheis
2007-Mar-12 00:29 UTC
[fxruby-users] I''m working on my graphics window for the ruby quiz
hi there, my experience with the @!$?%&-FXDCWindow and many other Widgets in FXRuby is, that they easily segfault if you pass nil as a param to a method that does expect some pointer to a widget. for instance in your code make sure that @canvas is not nil and that any other parameters.... you pass to the widgets are not nil and are of the expected type as stated by the API reference docs! PS: with fxdcwindow you can easily get segfaults when using the method to draw text without defining a standard font. also using a font that has not been created will segfault. now you know the reason for me heavily cursing on FXDCWindow ;) -- henon On 3/11/07, Lyle Johnson <lyle.johnson at gmail.com> wrote:> On 3/10/07, Raj Sahae <rajsahae at gmail.com> wrote: > > > And I have no idea how to get this canvas working. > > I''ve been looking at the scribble.rb example and trying to work off that. > > > > This is my display method, I get a seg fault when I run the method. > > > > def display > > FXDCWindow.new(@canvas) do |dc| > > @torus.grid.each_with_index do |row, y| > > row.each_with_index do |part, x| > > if part == :vapor > > dc.foreground = "blue" > > dc.drawPoint(x, y) > > elsif part == :vacuum > > dc.foreground = "black" > > dc.drawPoint(x, y) > > elsif part == :ice > > dc.foreground = "gray" > > dc.drawPoint(x, y) > > end > > end > > end > > end > > end > > I don''t see anything that is obviously wrong with it. It might help to > see the problem in context, though (i.e. in a complete program). > _______________________________________________ > fxruby-users mailing list > fxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/fxruby-users >