[MacRuby-devel] C-level blocks (issue #712)?
Rolando Abarca
rolando at gamesforfood.com
Tue Jan 11 09:40:05 PST 2011
Hi Laurent,
yes... I keep getting an "EXC_BAD_ACCESS" error, the backtrace would be:
#0 0x20052bbc0 in ??
#1 0x7fff823e0bd1 in -[NSApplication endSheet:returnCode:]
#2 0x1000f2dad in rb_objc_isEqual
#3 0x7fff822f2e9a in -[NSApplication sendAction:to:from:]
#4 0x7fff822f2df9 in -[NSControl sendAction:to:]
#5 0x7fff8237e76b in -[NSCell trackMouse:inRect:ofView:untilMouseUp:]
#6 0x7fff823af2aa in -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:]
#7 0x7fff8237d215 in -[NSControl mouseDown:]
here's my ruby code (the action executed by a button):
{{{
def loadFile(sender)
panel = NSOpenPanel.openPanel
panel.beginSheetModalForWindow(@window, completionHandler:Proc.new
{ |result|
NSLog("here: #{result}")
})
end
}}}
testing using macirb, I get the same seg fault:
{{{
$ macirb
irb(main):001:0> framework 'Foundation'
=> true
irb(main):002:0> a = [1,2,3,4,5]
=> [1, 2, 3, 4, 5]
irb(main):003:0> a.enumerateObjectsUsingBlock(Proc.new { |obj, index, stop|
irb(main):004:1> p obj
irb(main):005:1> stop.assign(true) if index == 2
irb(main):006:1> })
Segmentation fault
$
}}}
I'm using MacRuby 0.8
Thanks for any tip!
On Sun, Jan 9, 2011 at 7:22 PM, Laurent Sansonetti
<lsansonetti at apple.com> wrote:
> Hi Rolando,
>
> The syntax is simple, you simply pass a Proc project.
>
> Here is an example:
> framework 'Foundation'
> a = [1, 2, 3, 4, 5]
> a.enumerateObjectsUsingBlock(Proc.new { |obj, index, stop|
> p obj
> stop.assign(true) if index == 2
> })
> It looks like the snippet you pasted should just work. Did you find a
> problem?
> Laurent
--
Rolando Abarca M.
Games For Food S.p.A.
http://www.gamesforfood.com
Phone: +1 (408) 345-5433
More information about the MacRuby-devel
mailing list