And when I say “issue”, I really mean “crash”.
There wasn’t any information about a ruby-cocoa mailing list on
rubycocoa.sf.net, so I’m posting this question here. If there’s
a better place to ask for rb-cocoa help, let me know.
I’m going through the “Cocoa Programming for Mac OS X” book, but
using Ruby to implement each project instead of, or sometimes in
addition to, objective-c.
Things have been going fine, but I’ve run into an issue which I
can’t resolve. For those of you who have the book, I’m on page
104, attempting to delegate from NSSpeechSynthesizer.
My class, AppController, has implemented the
speechSynthesizer_didFinishSpeaking method like so:
def speechSynthesizer_didFinishSpeaking(sender, finish)
puts "speech stopped, finish = #{finish.to_i}"
end
… and awakeFromNib sets up the delegation from the speech
synthesizer like so:
def awakeFromNib
puts "AppController#awakeFromNib"
@speechSynth = NSSpeechSynthesizer.alloc.initWithVoice(nil)
@speechSynth.setDelegate(self)
puts "setting initial color for color well"
@colorWell.setColor(@textField.textColor)
end
Now, if I click on the “Stop” button, causing my “stop” method to
get called, the delegate callback method works fine. The finish
boolean is 0, as expected in this case:
def stop(sender)
@speechSynth.stopSpeaking
end
however, if I let the speech complete instead of stopping
before the end, my application crashes. Because of the lack of
debugger integration with ruby/cocoa, I don’t get much help when
this happens, either.
Here’s the backtrace from the GDB console at the time of the
crash:
(gdb) bt
#0 0x90a460f0 in objc_msgSend ()
#1 0x000a1638 in ocid_get_rbobj ()
#2 0x0006f814 in ocid_to_rbobj ()
#3 0x0006efc8 in ocdata_to_rbobj ()
#4 0x000718a8 in override_mixin_class_method_list ()
#5 0x00071d0c in override_mixin_class_method_list ()
#6 0x000720d0 in override_mixin_class_method_list ()
#7 0x00070ba4 in ocstr_to_rbstr ()
#8 0x9296a034 in -[NSObject(NSForwardInvocation) forward::] ()
#9 0x90a4b0b0 in _objc_msgForward ()
#10 0x93bb3f4c in -[NSSpeechSynthesizer _handleSpeechDoneCallback] ()
#11 0x92983a00 in __NSFireMainThreadPerform ()
#12 0x90814a78 in __CFRunLoopPerformPerform ()
#13 0x907e44cc in __CFRunLoopDoSources0 ()
#14 0x907e39fc in __CFRunLoopRun ()
#15 0x907e347c in CFRunLoopRunSpecific ()
#16 0x9321d980 in RunCurrentEventLoopInMode ()
#17 0x9321d014 in ReceiveNextEventCommon ()
#18 0x9321ce80 in BlockUntilNextEventMatchingListInMode ()
#19 0x9371fe84 in _DPSNextEvent ()
#20 0x9371fb48 in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#21 0x9371c08c in -[NSApplication run] ()
#22 0x9380cbfc in NSApplicationMain ()
#23 0x00076f50 in init_NSAlert ()
#24 0x966b50c8 in rb_with_disable_interrupt ()
#25 0x966b5a84 in rb_with_disable_interrupt ()
#26 0x966b02e0 in rb_Array ()
#27 0x966ac0b0 in ruby_cleanup ()
#28 0x966ac10c in ruby_exec ()
#29 0x966ac154 in ruby_run ()
#30 0x00072658 in RBApplicationMain ()
#31 0x00002d00 in main (argc=1, argv=0xbffff8dc) at main.m:13
I’m running OS 10.4.6 (ppc) with the latest ruby/cocoa package
(0.4.2?).
If anyone has any idea what might be going on here, please let
me know. BTW, the equivilant objective-c implementation works
correctly for me, so hopefully that means I’m not doing something
dumb and there is a bug here…
Thanks in advance,
Josh