[MacRuby-devel] Strange behaviour when using a Proc for a callback

2011-02-02 Thread Mark Rada
Hi,

I was trying to setup an async callback using a proc instead of a method to 
register for app launching notifications. For some reason, when I use the proc 
method, I get the wrong object passed to the proc
when it gets called.

The version using a method callback:

framework 'Cocoa'

def callback notif
  puts notif.class
  puts notif.inspect
  puts notif.userInfo.inspect
end

def launch_mail
  workspace = NSWorkspace.sharedWorkspace

  workspace.notificationCenter.addObserver self,
  selector:'callback:',
  
name:NSWorkspaceDidLaunchApplicationNotification,
object:nil

  workspace.launchAppWithBundleIdentifier 'com.apple.mail',
  options:NSWorkspaceLaunchAsync,
   additionalEventParamDescriptor:nil,
 launchIdentifier:nil
end

launch_mail
NSRunLoop.currentRunLoop.runUntilDate( Time.now + 5 )


That code will work the way that I expected it to, but if I try to use a proc:


framework 'Cocoa'

callback = Proc.new { |notif|
  puts notif.class
  puts notif.inspect
  puts notif.userInfo.inspect
}

workspace = NSWorkspace.sharedWorkspace

workspace.notificationCenter.addObserver callback,
selector:'call:',

name:NSWorkspaceDidLaunchApplicationNotification,
  object:nil

workspace.launchAppWithBundleIdentifier 'com.apple.mail',
options:NSWorkspaceLaunchAsync,
 additionalEventParamDescriptor:nil,
   launchIdentifier:nil

NSRunLoop.currentRunLoop.runUntilDate( Time.now + 5 )


It will crash because for some reason I am not getting the notification back as 
I should, instead I am getting a reference to the NSDictionary class.

I don't think this is the intended behaviour in MacRuby, but I'm not sure if 
what I am trying to do is supported. 

Is the ability to use a proc as a callback a supported feature? It has worked 
for me in other cases.


Mark Rada
mr...@marketcircle.com



___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] MacRuby Book discount

2011-02-02 Thread Eric Christopherson
This sale price is still good!
___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] IDE and TextEditor

2011-02-02 Thread Eric Christopherson
On Tue, Jan 18, 2011 at 8:32 PM, Robert Love wrote:

>
> Did anyone mention RedCar, the editor written in Ruby?  Do any users of it
> have good words to say about it?  Can it even run with MacRuby?
>

RedCar runs in JRuby and makes use of JVM-only things like SWT. I've tried
installing the gem for it in MacRuby, but I get the dread "argument out of
range" error (which I've gotten with some other gems too):

ERROR:  While executing gem ... (ArgumentError)
argument out of range
___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


[MacRuby-devel] "incorrect checksum for freed object" with Nokogiri (w/simple test case)

2011-02-02 Thread Andre Lewis
Hello,

Nokogiri started working with MacRuby 0.8, which is awesome. However, I'm
getting sporadic crashes: "incorrect checksum for freed object - object was
probably modified after being freed."

It doesn't crash every time I run the test, but if I run it 10 times, I get
one or more failures.

***Self-contained script to reproduce:*** https://gist.github.com/797346.

***Example crash output:***

$ macruby nokogiri_test.rb
starting
Nokogiri parsed the html
Run # 0: OK
Run # 1: OK macruby(59860,0x100f81000) malloc: *** error for object
0x10944ce38: incorrect checksum for freed object - object was probably
modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Abort trap

***My Nokogiri info:***

$ nokogiri -v
---
warnings: []
nokogiri: 1.4.4
ruby:
  version: 1.9.2
  platform: universal-darwin10.0
  engine: macruby
libxml:
  binding: extension
  compiled: 2.7.3
  loaded: 2.7.3

***MacRuby Info***

$ macruby -v
MacRuby 0.8 (ruby 1.9.2) [universal-darwin10.0, x86_64]


I posted to the Nokogiri list (
https://github.com/tenderlove/nokogiri/issues/issue/406). The test case runs
on all the other Ruby versions we've tried, so it seems Macruby-specific.

Any insight appreciated!

Andre
___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] "incorrect checksum for freed object" with Nokogiri (w/simple test case)

2011-02-02 Thread Vincent Isambart
Hi,

> Nokogiri started working with MacRuby 0.8, which is awesome. However, I'm
> gettingĀ sporadic crashes: "incorrect checksum for freed object - object was
> probably modified after being freed."
> It doesn't crash every time I run the test, but if I run it 10 times, I get
> one or more failures.
> **Self-contained script to reproduce:** https://gist.github.com/797346.

I tried running this test on trunk at least 20 times and I didn't get
any incorrect checksum error or any crash. I suspect it's a bug
already fixed in trunk (maybe
http://www.macruby.org/trac/changeset/5191/).

If you don't want to compile MacRuby by hand you may want to try the
nighly builds: http://www.macruby.org/files/nightlies/
___
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel