Add defensive handling for speaking empty strings, which appears to crash the client.
This commit is contained in:
parent
369bf23fa9
commit
2758f79538
|
@ -118,13 +118,21 @@ impl Connection {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn say<S: Into<String>>(&self, priority: Priority, text: S) -> bool {
|
pub fn say<S: Into<String>>(&self, priority: Priority, text: S) -> bool {
|
||||||
let param = CString::new(text.into()).unwrap();
|
let text: String = text.into();
|
||||||
|
if text.is_empty() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
let param = CString::new(text).unwrap();
|
||||||
let v = unsafe { spd_say(self.connection, priority as u32, param.as_ptr()) };
|
let v = unsafe { spd_say(self.connection, priority as u32, param.as_ptr()) };
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sayf<S: Into<String>>(&self, priority: Priority, format: S) -> bool {
|
pub fn sayf<S: Into<String>>(&self, priority: Priority, format: S) -> bool {
|
||||||
let param = CString::new(format.into()).unwrap();
|
let format: String = format.into();
|
||||||
|
if format.is_empty() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
let param = CString::new(format).unwrap();
|
||||||
let v = unsafe { spd_sayf(self.connection, priority as u32, param.as_ptr()) };
|
let v = unsafe { spd_sayf(self.connection, priority as u32, param.as_ptr()) };
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user