node-based graph editor
git clone https://git.lucas.co/cce-graph.git
refactor: paint-walk calls become shared borrows (painter slice 5)
The unsafe self-alias blocks existed only to mint *mut walk arguments;
paint_root_into takes &dyn WidgetHost now.
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01N4ajhvVZtyEEEus9bodsj3
src/main.rs | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index e7d22f3..2e15544 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1211,16 +1211,14 @@ impl Application for GraphApp {
}
}
{
- let self_ptr = self as *mut Self;
- let tops: [*mut (dyn cce_ui::widget::WidgetHost + 'static); 5] = unsafe {
- [
- (*self_ptr).menu_bar.as_ptr_mut(),
- (*self_ptr).dropdown_file.as_ptr_mut(),
- (*self_ptr).dropdown_edit.as_ptr_mut(),
- (*self_ptr).dropdown_view.as_ptr_mut(),
- (*self_ptr).graph.as_ptr_mut(),
- ]
- };
+ // The walk takes shared borrows now — no self-alias, no pointers.
+ let tops: [&dyn cce_ui::widget::WidgetHost; 5] = [
+ &self.menu_bar,
+ &self.dropdown_file,
+ &self.dropdown_edit,
+ &self.dropdown_view,
+ &self.graph,
+ ];
for top in tops {
cce_ui::scene::painter::paint_root_into(&self.ui_context, top, &mut pc);
}
@@ -1242,9 +1240,7 @@ impl Application for GraphApp {
pc.quad(rect, fill);
}
}
- let label_ptr: *mut (dyn cce_ui::widget::WidgetHost + 'static) =
- unsafe { (*(self as *mut Self)).control_panel_label.as_ptr_mut() };
- cce_ui::scene::painter::paint_root_into(&self.ui_context, label_ptr, &mut pc);
+ cce_ui::scene::painter::paint_root_into(&self.ui_context, &self.control_panel_label, &mut pc);
}
// Draw foreground images in the graph grid (above nodes, fully opaque, preserving aspect ratio)