things-to-remember checklist
git clone https://git.lucas.co/cce-list.git
refactor: hold widgets in Owned boxes (cce-ui Owned<W>)
The UiContext registry keeps raw pointers to registered widgets, and a
widget that moved while registered (its Vec reallocating, its struct
returned by value) left one pointing at the old address. Each widget
field is now an Owned<Adapted<..>> — a heap box whose allocation, not the
widget, carries the liveness token the registry watches — so the
registered address never moves and is dropped from the registry when the
box is freed. Field access is unchanged through Deref; construction
sites wrap in Owned::new.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
src/main.rs | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index 3569d2d..7738cd6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -22,6 +22,7 @@ use cce_list::{
delete_list, lists_dir, load_current, load_lists, save_current, save_list, Item, ListFile,
};
use vault_tasks::{Row, VaultTasks};
+use cce_ui::widget::Owned;
use cce_ui::engine::{Application, EngineState, LogicalPosition, LogicalSize, WindowSettings};
use cce_ui::scene::layout::Rect;
use cce_ui::scene::paint::{Cap, DisplayList, PaintCtx};
@@ -162,8 +163,8 @@ struct ListApp {
lists: Vec<ListFile>,
cur: usize,
mode: Mode,
- switcher: Adapted<Dropdown>,
- input_box: Adapted<TextBox>,
+ switcher: Owned<Adapted<Dropdown>>,
+ input_box: Owned<Adapted<TextBox>>,
ui_context: cce_ui::context::UiContext,
width: u32,
height: u32,
@@ -577,8 +578,8 @@ impl Application for ListApp {
lists: Vec::new(),
cur: 0,
mode: Mode::Items,
- switcher: Dropdown::new(Vec::new(), 0),
- input_box: TextBox::new(String::new()).with_placeholder(ITEM_PLACEHOLDER),
+ switcher: Owned::new(Dropdown::new(Vec::new(), 0)),
+ input_box: Owned::new(TextBox::new(String::new()).with_placeholder(ITEM_PLACEHOLDER)),
ui_context: cce_ui::context::UiContext::new(),
width: INIT_W,
height: INIT_H,