diff --git a/src/main.rs b/src/main.rs index df408aa..bff29de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,6 +54,9 @@ enum Message { struct State { table: data::Table, content: widget::text_editor::Content, + + /// has the application initialized successfully? + ok: bool, } impl State { fn new() -> Self { @@ -72,6 +75,8 @@ impl State { } } + state.ok = true; + state } fn view(&self) -> Element<'_, Message, Theme, Renderer> { @@ -236,6 +241,11 @@ impl State { } impl Drop for State { fn drop(&mut self) { + if !self.ok { + eprintln!("app failed to start, not saving data"); + return; + } + ron::Options::default() .to_io_writer( fs::File::create(data!()).unwrap(), @@ -245,6 +255,8 @@ impl Drop for State { }, ) .unwrap(); + + eprintln!("successfully saved data"); } }