mirror of https://github.com/ndarilek/tts-rs.git
#35 Fix AppKit crash when interrupting speech
avoid removing first string when queue already empty
This commit is contained in:
parent
b4f48fa439
commit
94615a254a
|
@ -46,16 +46,18 @@ impl AppKit {
|
||||||
) {
|
) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let strings: id = *this.get_ivar("strings");
|
let strings: id = *this.get_ivar("strings");
|
||||||
let str: id = msg_send!(strings, firstObject);
|
|
||||||
let _: () = msg_send![str, release];
|
|
||||||
let _: () = msg_send!(strings, removeObjectAtIndex:0);
|
|
||||||
let count: u32 = msg_send![strings, count];
|
let count: u32 = msg_send![strings, count];
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
|
let str: id = msg_send!(strings, firstObject);
|
||||||
|
let _: () = msg_send![str, release];
|
||||||
|
let _: () = msg_send!(strings, removeObjectAtIndex:0);
|
||||||
|
if count > 1 {
|
||||||
let str: id = msg_send!(strings, firstObject);
|
let str: id = msg_send!(strings, firstObject);
|
||||||
let _: BOOL = msg_send![synth, startSpeakingString: str];
|
let _: BOOL = msg_send![synth, startSpeakingString: str];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
decl.add_method(
|
decl.add_method(
|
||||||
sel!(speechSynthesizer:didFinishSpeaking:),
|
sel!(speechSynthesizer:didFinishSpeaking:),
|
||||||
speech_synthesizer_did_finish_speaking
|
speech_synthesizer_did_finish_speaking
|
||||||
|
|
Loading…
Reference in New Issue