When I run the following code, I expect a blank frame to open (which is what happens when the def block is left out of the code). Instead, the program exits immediately. ruby 1.9.2p290 (2011-07-09) [i386-mingw32] wxruby 2.0.1 OS: Microsoft Windows XP Professional 5.1.2600 #!/usr/bin/ruby -w require "wx" Wx::App.run do Wx::Frame.new(nil).show def cause_of_problem puts "This prevents the window from staying open, even though it is never run" end end A perhaps related issue involves errors such as uninitialized variable accesses inside of event loops in Windows 7 -- I get no error message (even with $stdout.sync = true); instead, the application just stops responding, which makes debugging impractical. Has anyone else seen similar problems, and is wxruby debugging more robust under Linux? Thanks, Eric -- Posted via http://www.ruby-forum.com/.
Alex Fenton
2011-Oct-20 19:27 UTC
[wxruby-users] XP and Windows 7 -- def() inside App#run block problem
hi On 12/10/11 17:42, Eric B. wrote:> When I run the following code, I expect a blank frame to open (which is > what happens when the def block is left out of the code). Instead, the > program exits immediately. > > ruby 1.9.2p290 (2011-07-09) [i386-mingw32] > wxruby 2.0.1 > OS: Microsoft Windows XP Professional 5.1.2600 > > #!/usr/bin/ruby -w > > require "wx" > > Wx::App.run do > Wx::Frame.new(nil).show > > def cause_of_problem > puts "This prevents the window from staying open, even though it is > never run" > end > > endYou need to return a true value from App.run block to signal that the app set up successfully and the GUI loop should begin. The return value of the ''def'' is ''nil'', which evaluates to false. Adding any true value after the def block will fix this.> A perhaps related issue involves errors such as uninitialized variable > accesses inside of event loops in Windows 7 -- I get no error message > (even with $stdout.sync = true); instead, the application just stops > responding, which makes debugging impractical. > > Has anyone else seen similar problems, and is wxruby debugging more > robust under Linux?I''m afraid I haven''t used wxRuby on Windows 7, but on all the platforms I''ve used (Windows XP, Linux, OS X) I''d expect this kind of normal Ruby error to throw an exception and abort. alex
David Beswick
2011-Oct-20 20:51 UTC
[wxruby-users] XP and Windows 7 -- def() inside App#run block problem
It''s true that crashes in native code under Linux are much more helpful -- you get a backtrace into the native code. Under Windows in the past I''ve recompiled wxWidgets and wxRuby with debugging information, then have run ruby through the Visual Studio debugger to get this information, which is a pain. Maybe it would be possible to use Structured Exception Handling under Windows to catch exceptions such as null pointer accesses in wxruby code and provide more helpful information. David On Fri, Oct 21, 2011 at 6:27 AM, Alex Fenton <alex at pressure.to> wrote:> hi > > > On 12/10/11 17:42, Eric B. wrote: > >> When I run the following code, I expect a blank frame to open (which is >> what happens when the def block is left out of the code). Instead, the >> program exits immediately. >> >> ruby 1.9.2p290 (2011-07-09) [i386-mingw32] >> wxruby 2.0.1 >> OS: Microsoft Windows XP Professional 5.1.2600 >> >> #!/usr/bin/ruby -w >> >> require "wx" >> >> Wx::App.run do >> Wx::Frame.new(nil).show >> >> def cause_of_problem >> puts "This prevents the window from staying open, even though it is >> never run" >> end >> >> end >> > > You need to return a true value from App.run block to signal that the app > set up successfully and the GUI loop should begin. > > The return value of the ''def'' is ''nil'', which evaluates to false. Adding > any true value after the def block will fix this. > > > A perhaps related issue involves errors such as uninitialized variable >> accesses inside of event loops in Windows 7 -- I get no error message >> (even with $stdout.sync = true); instead, the application just stops >> responding, which makes debugging impractical. >> >> Has anyone else seen similar problems, and is wxruby debugging more >> robust under Linux? >> > > I''m afraid I haven''t used wxRuby on Windows 7, but on all the platforms > I''ve used (Windows XP, Linux, OS X) I''d expect this kind of normal Ruby > error to throw an exception and abort. > > alex > > ______________________________**_________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/**listinfo/wxruby-users<http://rubyforge.org/mailman/listinfo/wxruby-users> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/wxruby-users/attachments/20111021/d800202b/attachment.html>