git.lucas.co / cce-notes
notes editor over the vault (Obsidian-compatible)
git clone https://git.lucas.co/cce-notes.git

commitc51abdbd3a33f101fa3fd3910bf88cda9035ca23
parentaa6af2e793
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 | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index da478b8..2094739 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1734,10 +1734,8 @@ impl Application for NotesApp {
     fn display_list(&mut self, size: LogicalSize, scale: f64) -> Option<DisplayList> {
         if !self.widgets_registered {
             self.widgets_registered = true;
-            let (id, ptr) = (self.switcher_input.id(), self.switcher_input.as_ptr_mut());
-            self.ui_context.register_widget(id, ptr);
-            let (id, ptr) = (self.search_input.id(), self.search_input.as_ptr_mut());
-            self.ui_context.register_widget(id, ptr);
+            self.ui_context.register_host(&mut self.switcher_input);
+            self.ui_context.register_host(&mut self.search_input);
         }
         let size_changed =
             self.width != size.width as u32 || self.height != size.height as u32 || self.scale != scale;