[MacRuby-devel] C-level blocks (issue #712)?

Matt Aimonetti mattaimonetti at gmail.com
Sun Jan 9 12:22:01 PST 2011


>
> I suspect this has to do with keeping a reference so it doesn't get GC'd.
> Just a hunch. Am I getting there?
>

That's my guess too, if you pass the lambda as a param, it might get GC'd
and when the panel is done, it won't have a reference to the handler.

- Matt

On Sun, Jan 9, 2011 at 11:46 AM, Caio Chassot <lists at caiochassot.com> wrote:

> So It seems to me the only change there is uninlining the lambda and
> assigning it to a throwaway variable. That feels like busywork.
>
> I suspect this has to do with keeping a reference so it doesn't get GC'd.
> Just a hunch. Am I getting there?
>
> Why is this needed?
>
>
> On 2011-01-09, at 17:10 , Matt Aimonetti wrote:
> >
> > I realize I didn't really reply to your question, the following code
> should
> > work:
> >
> > {{{
> > def loadSprite(sender)
> >   handler = lambda do |code|
> >     return if code == NSCancelButton
> >     # do things with the panel's date otherwise
> >  end
> >
> >   @panel.beginSheetModalForWindow(@window, completionHandler: handler)
> > end
> > }}}
> >
> > - Matt
> >
> >
> > On Sun, Jan 9, 2011 at 8:09 AM, Rolando Abarca <rolando at gamesforfood.com
> >wrote:
> >
> >> Hi all,
> >>
> >> I've taken a look at the referred issue (#712), but I'm not sure of
> >> the final implemented syntax. I'm trying to use a NSOpenPanel, so far
> >> this is what I'm doing:
> >>
> >>
> >> {{{
> >> def loadSprite(sender)
> >>   @panel.beginSheetModalForWindow(@window, completionHandler:lambda {
> >> |code|
> >>     NSLog("code: #{code}")
> >>   })
> >> end
> >> }}}
> >>
> >> what's the Right Way(tm) to use a NSOpenPanel?
> >> thanks!
> >> --
> >> Rolando Abarca M.
> >> Games For Food S.p.A.
> >> http://www.gamesforfood.com
> >> Phone: +1 (408) 345-5433
> >> _______________________________________________
> >> MacRuby-devel mailing list
> >> MacRuby-devel at lists.macosforge.org
> >> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
> >>
> > _______________________________________________
> > MacRuby-devel mailing list
> > MacRuby-devel at lists.macosforge.org
> > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20110109/acc838fa/attachment.html>


More information about the MacRuby-devel mailing list