From: Olaf Wintermann Date: Tue, 26 May 2026 15:13:29 +0000 (+0200) Subject: handle cstr.is_null in UiString/UiText get methods X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fmain;p=note.git handle cstr.is_null in UiString/UiText get methods --- diff --git a/ui-rs/src/ui/toolkit.rs b/ui-rs/src/ui/toolkit.rs index 25aa0c1..708c22e 100644 --- a/ui-rs/src/ui/toolkit.rs +++ b/ui-rs/src/ui/toolkit.rs @@ -604,9 +604,13 @@ impl UiText { pub fn get(&self) -> String { unsafe { let cstr = ui_text_get(self.ptr); - CStr::from_ptr(cstr) - .to_string_lossy() - .into_owned() + if !cstr.is_null() { + CStr::from_ptr(cstr) + .to_string_lossy() + .into_owned() + } else { + "".to_owned() + } } } @@ -701,9 +705,13 @@ impl UiString { pub fn get(&self) -> String { unsafe { let cstr = ui_string_get(self.ptr); - CStr::from_ptr(cstr) - .to_string_lossy() - .into_owned() + if !cstr.is_null() { + CStr::from_ptr(cstr) + .to_string_lossy() + .into_owned() + } else { + "".to_owned() + } } }