Instantiating a Wx::Bitmap with width and height causes a segmentation fault. This is the minimal example I could find where the behaviour is exhibited: require 'rubygems' require 'wx' Wx::Bitmap.new(1, 1) Results in: /usr/lib/ruby/gems/1.8/gems/wxruby-1.9.8-x86-linux/lib/wx/classes/bitmap.rb:17: [BUG] Segmentation fault ruby 1.8.6 (2007-09-24) [i486-linux] Note that without width and height, no segmentation fault is caused: Wx::Bitmap.new // => #<Wx::Bitmap:0xb5eef164> I'm running Ubuntu Hardy 8.04, ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux], wxwidgets 1.9.6, and have the following wx-packages installed: libwxbase2.6-0 18.104.22.168.2-2ubuntu4 libwxbase2.8-0 22.214.171.124-0ubuntu3 libwxbase2.8-dev 126.96.36.199-0ubuntu3 libwxgtk2.6-0 188.8.131.52.2-2ubuntu4 libwxgtk2.8-0 184.108.40.206-0ubuntu3 libwxgtk2.8-dev 220.127.116.11-0ubuntu3 wx2.8-headers 18.104.22.168-0ubuntu3 Any help is greatly appreciated! - andreas
on 2008-10-13 13:43
on 2008-10-13 16:20
Andreas GarnÃ¦s wrote: > I'm running Ubuntu Hardy 8.04, ruby 1.8.6 (2007-09-24 patchlevel 111) > [i486-linux], wxwidgets 1.9.6, and have the following wx-packages > installed: [...] Correction: I'm actually running wxwidgets 1.9.8.
on 2008-10-25 15:49
Hi Andreas Sorry for the delay in replying. Andreas Garnæs wrote: > Instantiating a Wx::Bitmap with width and height causes a segmentation > fault. This is the minimal example I could find where the behaviour is > exhibited: > > require 'rubygems' > require 'wx' > Wx::Bitmap.new(1, 1) The problem here is not that Wx::Bitmap.new(width, height) segfault, but that you can't instantiate Bitmap (or similarly, Font, I guess) outside of the main loop. In other words, you can't call Bitmap.new until after you've called App.run or App.main_loop. It works fine otherwise (tested SVN HEAD on GTK). This restriction is inherited from Wx, unfortunately. Bitmap is a platform-specific representation of an image, and wraps a C++ native gui object. These can't be created until various setup steps have been done. The no-argument version is an exception because no real resource is created. There are different ways round this - ArtProvider provides a way of retrieving and caching standard images. Following this I've added a note to the documentation of Bitmap and Font to say they shouldn't be created outside of main_loop. cheers alex