From lists at ruby-forum.com Sat Feb 5 08:34:28 2011 From: lists at ruby-forum.com (Jason Knott) Date: Sat, 05 Feb 2011 14:34:28 +0100 Subject: [wxruby-users] Event syntax Message-ID: <1ad2cf353b1da9ffef719b8ce22bf039@ruby-forum.com> Class A is a ruby file generated from XRC via xrcise. Class B is a child class that inherits from class A, and subsequently is where I have my event hook-ups defined (just in case I need to generate class A from XRC again, I don't want the event code overwritten). My question is about the syntax for the event hookups. Why does the code below work the way it does? class B < A def initialize super evt_menu(@m_menuAbout) { | event | onAbout(event) } #this works evt_menu(self.m_menuAbout) { | event | onAbout2(event) } #also works evt_menu(@m_menuAbout) { :onAbout3 } #does not work end def onAbout(event) puts 'You clicked the About menu' end def onAbout2(event) puts 'You clicked the About menu' end def onAbout3 puts 'You would have cliked the About menu but the code doesn't get here' end end Kind of new to ruby, so I'm not sure why I need to include the | event | syntax for the event hookup. Any explainations? Thanks! -- Posted via http://www.ruby-forum.com/. From alex at pressure.to Sat Feb 5 16:46:23 2011 From: alex at pressure.to (Alex Fenton) Date: Sat, 05 Feb 2011 21:46:23 +0000 Subject: [wxruby-users] Event syntax In-Reply-To: <1ad2cf353b1da9ffef719b8ce22bf039@ruby-forum.com> References: <1ad2cf353b1da9ffef719b8ce22bf039@ruby-forum.com> Message-ID: <4D4DC52F.9010202@pressure.to> Hi Jason On 05/02/11 13:34, Jason Knott wrote: > def initialize > super > evt_menu(@m_menuAbout) { | event | onAbout(event) } #this works > evt_menu(self.m_menuAbout) { | event | onAbout2(event) } #also works > evt_menu(@m_menuAbout) { :onAbout3 } #does not work > end Look at this code just from a general Ruby point of view. Your last example is a block / anonymous function that simply returns the symbol value :onAbout3. It is running (I'm pretty sure) but not doing anything interesting. I think what you want is evt_menu(@m_menuAbout, :onAbout3). Then the symbol is interpreted immediately by evt_menu, which takes it to mean "bind the method named "..." to the event handler". The bound method can accept an event argument, or not, as it pleases. best alex From lists at ruby-forum.com Mon Feb 7 15:48:21 2011 From: lists at ruby-forum.com (Garison Piatt) Date: Mon, 07 Feb 2011 21:48:21 +0100 Subject: [wxruby-users] Yet Another Segmentation Fault Message-ID: I've looked through the forum at the umpteen threads about segmentation faults, and none of them seem to address my problem. I'm hoping someone can point out what I need to do. Platform: Vista Ruby v#: 1.9.1 wxRuby: 2.0.1 I'm running a minimal window, which I have on good authority will work: require "wx" include Wx class MinimalApp < App def on_init Frame.new(nil, -1, "The Bare Minimum").show() end end MinimalApp.new.main_loop When I run it, I get the following: ================================== C:\Ruby\apps>ruby minimal.rb C:/Ruby/wxruby/ruby/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-x86-mingw32/lib/wxruby2.so: [BUG] Segmentation fault ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-mingw32] -- control frame ---------- c:0008 p:-9633262 s:0021 b:0021 l:000020 d:000020 TOP c:0007 p:---- s:0019 b:0019 l:000018 d:000018 CFUNC :require c:0006 p:0011 s:0015 b:0015 l:000014 d:000014 TOP C:/Ruby/wxruby/ruby/lib/rub y/gems/1.9.1/gems/wxruby-2.0.1-x86-mingw32/lib/wx.rb:12 c:0005 p:---- s:0012 b:0012 l:000011 d:000011 FINISH c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC :require c:0003 p:0011 s:0006 b:0006 l:000e84 d:001e2c EVAL minimal.rb:1 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH c:0001 p:0000 s:0002 b:0002 l:000e84 d:000e84 TOP --------------------------- -- Ruby level backtrace information----------------------------------------- C:/Ruby/wxruby/ruby/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-x86-mingw32/lib/wx.rb: 12:in `require' C:/Ruby/wxruby/ruby/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-x86-mingw32/lib/wx.rb: 12:in `' minimal.rb:1:in `require' minimal.rb:1:in `
' [NOTE] You may encounter a bug of Ruby interpreter. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. ================================== Any idea what I need to fix, replace, install or whatever to fix this? -- Posted via http://www.ruby-forum.com/. From sutniuq at gmx.net Mon Feb 7 16:28:11 2011 From: sutniuq at gmx.net (Quintus) Date: Mon, 07 Feb 2011 22:28:11 +0100 Subject: [wxruby-users] Yet Another Segmentation Fault In-Reply-To: References: Message-ID: <4D5063EB.10607@gmx.net> Am 07.02.2011 21:48, schrieb Garison Piatt: > C:/Ruby/wxruby/ruby/lib/ruby/gems/1.9.1/gems/wxruby-2.0.1-x86-mingw32/lib/wxruby2.so: That looks as if you installed the wxRuby gem for Ruby 1.8. Try gem uninstall wxruby gem install wxruby-ruby19 Vale, Marvin From lists at ruby-forum.com Mon Feb 7 20:05:47 2011 From: lists at ruby-forum.com (Garison Piatt) Date: Tue, 08 Feb 2011 02:05:47 +0100 Subject: [wxruby-users] Yet Another Segmentation Fault In-Reply-To: <4D5063EB.10607@gmx.net> References: <4D5063EB.10607@gmx.net> Message-ID: Marvin G?lker wrote in post #980137: > That looks as if you installed the wxRuby gem for Ruby 1.8. Try > gem uninstall wxruby > gem install wxruby-ruby19 You are a god. Thank you. -garison -- Posted via http://www.ruby-forum.com/. From dwilde1 at gmail.com Tue Feb 8 16:10:35 2011 From: dwilde1 at gmail.com (Don Wilde) Date: Tue, 8 Feb 2011 13:10:35 -0800 Subject: [wxruby-users] timing issue Message-ID: I believe I've run afoul of a timing issue in wxruby that might explain some peoples' segfaults. I have a radio button page as part of a notebook that selects a file to read in, which triggers a whole lot of other changes, including a rebuild of one of the other notebook pages. If I'm slow and deliberate (like 2+ seconds between clicks) it all works fine. However, if I click faster, I WILL get a segfault. Since my printed puts statements are all executing, my processing is being completed. Unfortunately, it appears that there is still background processing occurring at either the wxruby or wxW level that is not protected against such occurrences. How can I test for this and either defer the click processing or veto it? -- -- Don Wilde ph: 512-394-8896 skype: donwilde1 e: dwilde1 at gmail.com "If you are creative and add value to the world, sleep well. You've earned it." -------------- next part -------------- An HTML attachment was scrubbed... URL: From hars at pre-sense.de Wed Feb 9 03:22:43 2011 From: hars at pre-sense.de (Florian Hars) Date: Wed, 09 Feb 2011 09:22:43 +0100 Subject: [wxruby-users] timing issue In-Reply-To: References: Message-ID: <4D524ED3.9080907@pre-sense.de> On 08.02.2011 22:10, Don Wilde wrote: > How can I test for this and either defer the click processing or veto it? I think the main problem is that the integration with the garbage collector is buggy and if enough stuff happens between when your object becomes garbage and when it is actually collected some data structures become corrupted. For example, I can completely avoid the segfaults in http://rubyforge.org/tracker/index.php?func=detail&aid=28871&group_id=35&atid=218 by immediately calling GC.start() after destroying the temporary windows, and the probability of a segfault goes down if I decrease the timer interval so it runs more often so more stuff gets allocated and the collector runs more often. - Florian. From dwilde1 at gmail.com Wed Feb 9 12:24:02 2011 From: dwilde1 at gmail.com (Don Wilde) Date: Wed, 9 Feb 2011 09:24:02 -0800 Subject: [wxruby-users] timing issue In-Reply-To: <4D524ED3.9080907@pre-sense.de> References: <4D524ED3.9080907@pre-sense.de> Message-ID: On Wed, Feb 9, 2011 at 12:22 AM, Florian Hars wrote: > On 08.02.2011 22:10, Don Wilde wrote: > > How can I test for this and either defer the click processing or veto it? > > I think the main problem is that the integration with the garbage > collector is buggy and if enough stuff happens between when your object > becomes garbage and when it is actually collected some data structures > become corrupted. For example, I can completely avoid the segfaults in > > http://rubyforge.org/tracker/index.php?func=detail&aid=28871&group_id=35&atid=218 > by immediately calling GC.start() after destroying the temporary > windows, and the probability of a segfault goes down if I decrease the > timer interval so it runs more often so more stuff gets allocated and > the collector runs more often. > > That does make a scary kind of sense. I reconstitute an entire tab book page with hundreds of elements on it, and of course the old elements become garbage. if this is known-buggy, and nobody knows a better way to identify completion of the cleanup, I'll have to rig another timer to defer the new operations for a few seconds. I'll add the explicit call like you suggest, too, Florian. Thanks for the understanding and tips. -- -- Don Wilde ph: 512-394-8896 skype: donwilde1 e: dwilde1 at gmail.com "If you are creative and add value to the world, sleep well. You've earned it." -------------- next part -------------- An HTML attachment was scrubbed... URL: From dwilde1 at gmail.com Wed Feb 9 13:33:35 2011 From: dwilde1 at gmail.com (Don Wilde) Date: Wed, 9 Feb 2011 10:33:35 -0800 Subject: [wxruby-users] timing issue In-Reply-To: References: <4D524ED3.9080907@pre-sense.de> Message-ID: On Wed, Feb 9, 2011 at 9:24 AM, Don Wilde wrote: > > > On Wed, Feb 9, 2011 at 12:22 AM, Florian Hars wrote: > >> On 08.02.2011 22:10, Don Wilde wrote: >> > [snip] > by immediately calling GC.start() after destroying the temporary >> windows, and the probability of a segfault goes down if I decrease the >> timer interval so it runs more often so more stuff gets allocated and >> the collector runs more often. >> >> That does make a scary kind of sense. I reconstitute an entire tab book > page with hundreds of elements on it, and of course the old elements become > garbage. > > if this is known-buggy, and nobody knows a better way to identify > completion of the cleanup, I'll have to rig another timer to defer the new > operations for a few seconds. > > I'll add the explicit call like you suggest, too, Florian. Thanks for the > understanding and tips. > > Florian, the explixcit GC call was indeed all I needed. Many thanks! :D -- -- Don Wilde ph: 512-394-8896 skype: donwilde1 e: dwilde1 at gmail.com "If you are creative and add value to the world, sleep well. You've earned it." -------------- next part -------------- An HTML attachment was scrubbed... URL: