login authentication (PAM + fingerprint)
git clone https://git.lucas.co/cce-authenticator.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 | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/main.rs b/src/main.rs
index 1c33533..618a33c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,5 @@
use wayland_client::QueueHandle;
+use cce_ui::widget::Owned;
use cce_ui::engine::{Application, EngineState, LogicalPosition, LogicalSize, WindowSettings};
use cce_ui::widget::{
Button, WidgetHost, ElementState, MouseButton, Key, NamedKey, KeyEvent, TextBox,
@@ -144,10 +145,10 @@ fn take_cancelled(cookie: &str) -> bool {
}
struct AuthenticatorApp {
- password_box: cce_ui::widget::Adapted<TextBox>,
- verify_btn: cce_ui::widget::Adapted<cce_ui::widget::Button>,
- cancel_btn: cce_ui::widget::Adapted<cce_ui::widget::Button>,
- fingerprint_btn: cce_ui::widget::Adapted<cce_ui::widget::Button>,
+ password_box: Owned<cce_ui::widget::Adapted<TextBox>>,
+ verify_btn: Owned<cce_ui::widget::Adapted<cce_ui::widget::Button>>,
+ cancel_btn: Owned<cce_ui::widget::Adapted<cce_ui::widget::Button>>,
+ fingerprint_btn: Owned<cce_ui::widget::Adapted<cce_ui::widget::Button>>,
status_msg: String,
status_is_error: bool,
@@ -327,10 +328,10 @@ impl Application for AuthenticatorApp {
}
let mut app = Self {
- password_box,
- verify_btn,
- cancel_btn,
- fingerprint_btn,
+ password_box: Owned::new(password_box),
+ verify_btn: Owned::new(verify_btn),
+ cancel_btn: Owned::new(cancel_btn),
+ fingerprint_btn: Owned::new(fingerprint_btn),
status_msg,
status_is_error: false,