From 124c30805ea6f9dbc775b63ee1dd32701440001f Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Tue, 26 May 2026 17:13:29 +0200 Subject: [PATCH] handle cstr.is_null in UiString/UiText get methods --- ui-rs/src/ui/toolkit.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) 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() + } } } -- 2.47.3