cloud storage client
git clone https://git.lucas.co/cce-cloud.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 b7dac6a..1c5071f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,4 @@
+use cce_ui::widget::Owned;
use cce_ui::widget::ScrollRegion;
use std::sync::{Arc, Mutex};
@@ -1759,8 +1760,8 @@ struct State {
/// launched window on that grid square.
invoked_at: Option<(i32, i32)>,
- fuzzel: cce_ui::widget::Adapted<FuzzelWidget>,
- json_layout: Option<cce_ui::widget::Adapted<JsonLayoutWidget>>,
+ fuzzel: Owned<cce_ui::widget::Adapted<FuzzelWidget>>,
+ json_layout: Option<Owned<cce_ui::widget::Adapted<JsonLayoutWidget>>>,
font_system: FontSystem,
swash_cache: SwashCache,
@@ -2167,8 +2168,8 @@ impl State {
frame_batches: Vec::new(),
frame_images: Vec::new(),
plate_features: Vec::new(),
- fuzzel,
- json_layout,
+ fuzzel: Owned::new(fuzzel),
+ json_layout: json_layout.map(Owned::new),
font_system,
swash_cache,
cursor_x: 0.0,