git.lucas.co / cce-files
file manager
git clone https://git.lucas.co/cce-files.git

commit8278f5bbf3e15b6935b73957083f59bb2af0230e
parent3ae90e69d7
authorLucas Galante <lsgalante12@gmail.com>
date2026-10-07 15:30
refactor: register widgets by reference (UiContext::register_host)

register_widget(id, ptr) took a raw pointer in a safe function; cce-ui is
making it an unsafe fn now that every app registers through
register_host(&mut w), which takes the widget's own id and a live borrow.
Registration loops that existed only to hand the registry raw pointers
(and the unsafe blocks and self_ptr casts around them) are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

 src/main.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 34ebe0d..b279807 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -850,7 +850,7 @@ impl FilesystemApp {
             let self_ptr = self as *mut Self;
             unsafe {
                 if has_sidebar {
-                    self.ui_context.register_widget((*self_ptr).paginator.base().id(), (*self_ptr).paginator.as_ptr_mut());
+                    self.ui_context.register_host(&mut self.paginator);
                     (*self_ptr).paginator.set_parent(None, &mut self.ui_context);
                 }
             }
@@ -876,7 +876,7 @@ impl FilesystemApp {
         }
 
         if let Some(PromptDialog { textbox, .. }) = &mut self.prompt_dialog {
-            self.ui_context.register_widget(textbox.base().id(), textbox.as_ptr_mut());
+            self.ui_context.register_host(textbox);
             textbox.set_parent(None, &mut self.ui_context);
         }