Segmentation fault

Hi,
Thank you for publishing WxRuby. I am enjoying the time spent learning
how
to use it.

I now have a 2000 line program that has found a bug in the sample
printing.rb code and one in the WxRuby printing subsystem.

In the sample code for printing, svn - Revision 2112:
/trunk/wxruby/samples/printing/printing.rb, the page one code does not
scale
the graphics to the printed page size. For an a4 page it is printed at
the
same scale as it appears on screen. And while it prints the second page
okay
it shows a blank page in the printpreview window.

The error is that the scaling code is using integer division instead of
floating point division. The patch below fixes this bug.

274,275c274,275
< scale_x=(w/max_x)
< scale_y=(h/max_y)

scale_x=(w.to_f/max_x.to_f)
scale_y=(h.to_f/max_y.to_f)

321c321
< overall_scale = scale * (w/page_width)

overall_scale = scale * (w.fdiv(page_width))

The second bug is something that I can not fix. If I apply the following
patch to printing.rb, ruby will fail with a segmentation fault as I
dismiss
the page setup dialog every time.

If I dont apply the patch, the segmentation fault will only appear when
I
exit the application. I would appreciate your response on this matter.

170c170
< page_setup_dialog = Wx::PageSetupDialog.new(self,
Wx::get_app.page_setup_data)

page_setup_dialog = Wx::PageSetupDialog.new(nil,

Wx::get_app.page_setup_data)
174a175

page_setup_dialog.destroy()

I am using ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-mswin32] and
A wxRuby distribution for Windows bundling :

  • ruby-1.9.1-p243 with its minimal dependency (zlib, iconv) built with
    MinGW
  • wxRuby-2.0.1
    • built with wxWidgets-2.8.10
    • associated documentation and samples
  • ruby-opengl-0.60.1
  • RMagick-2.11.0 built with ImageMagick-6.5.5-6 with PNG/JPEG/TIFF
    support

Phillip Shelton