From 94615a254a0606fab12da4f5f00aec7cd26afe7a Mon Sep 17 00:00:00 2001 From: Benjamin Klum Date: Sun, 16 Oct 2022 23:18:19 +0200 Subject: [PATCH] #35 Fix AppKit crash when interrupting speech avoid removing first string when queue already empty --- src/backends/appkit.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/backends/appkit.rs b/src/backends/appkit.rs index cf1375a..f8a02b7 100644 --- a/src/backends/appkit.rs +++ b/src/backends/appkit.rs @@ -46,13 +46,15 @@ impl AppKit { ) { unsafe { 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]; if count > 0 { let str: id = msg_send!(strings, firstObject); - let _: BOOL = msg_send![synth, startSpeakingString: str]; + let _: () = msg_send![str, release]; + let _: () = msg_send!(strings, removeObjectAtIndex:0); + if count > 1 { + let str: id = msg_send!(strings, firstObject); + let _: BOOL = msg_send![synth, startSpeakingString: str]; + } } } }