git.lucas.co / cce-gallery
widget gallery and compositor test bench

commit55b284b07f157aad3f4e0ba7683516ed56109e3f
parenta494fc0c4d
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, 1 insertion(+), 3 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 6e7f205..b0fc6db 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1027,9 +1027,7 @@ impl State {
     /// through `render_widget`, where other apps pick registration up as a side effect.
     fn register_roster(&mut self) {
         for i in 0..self.roster.len() {
-            let w = self.roster.get_dyn_mut(i);
-            let (id, ptr) = (w.base().id(), w as *mut (dyn WidgetHost + 'static));
-            self.ui_context.register_widget(id, ptr);
+            self.ui_context.register_host(self.roster.get_dyn_mut(i));
         }
     }