From c76396a010f3f4caffa90feb6b09d9d1530b092e Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Thu, 10 Aug 2023 13:14:45 -0400 Subject: [PATCH] Shutdown properly when the main window closes --- dashboard/src/app_window.rs | 12 ------------ dashboard/src/main.rs | 15 ++++++--------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/dashboard/src/app_window.rs b/dashboard/src/app_window.rs index 10886bc..57456b4 100644 --- a/dashboard/src/app_window.rs +++ b/dashboard/src/app_window.rs @@ -43,16 +43,6 @@ impl ApplicationWindow { let date_label = Date::new(); layout.append(&date_label); - /* - let next_event = gtk::Label::builder() - .margin_bottom(8) - .margin_top(8) - .margin_start(8) - .margin_end(8) - .build(); - layout.append(&next_event); - */ - let events = Events::new(); layout.append(&events); @@ -75,8 +65,6 @@ impl ApplicationWindow { pub fn update_state(&self, state: State) { self.date_label.update_date(state.date); - /* self.next_event.set_text(&format!("{:?}", state.next_event)); */ - self.events.set_events(state.events, state.next_event); if let Some(transit) = state.transit { self.transit_card.update_transit(&transit); diff --git a/dashboard/src/main.rs b/dashboard/src/main.rs index 7af3529..c80ca52 100644 --- a/dashboard/src/main.rs +++ b/dashboard/src/main.rs @@ -81,18 +81,16 @@ pub fn main() { let latitude = Latitude::from(41.78); let longitude = Longitude::from(-71.41); - let runtime = Arc::new( - tokio::runtime::Builder::new_multi_thread() - .enable_all() - .build() - .unwrap(), - ); + let runtime = tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .unwrap(); let core = Core { tx: Arc::new(RwLock::new(None)), }; - let app_handle = runtime.spawn({ + let _ = runtime.spawn({ let core = core.clone(); async move { let soluna_client = SolunaClient::new(); @@ -142,6 +140,5 @@ pub fn main() { let args: Vec = env::args().collect(); ApplicationExtManual::run_with_args(&app, &args); - - let _ = runtime.block_on(async { app_handle.await }); + runtime.shutdown_background(); }