From 9cddbc570fb0f314b6590193f20283ba603ffd06 Mon Sep 17 00:00:00 2001 From: Horbin <2240045751@qq.com> Date: Sat, 28 Sep 2024 10:50:18 +0800 Subject: [PATCH] optimize: slint run into app run --- src/core/application/mod.rs | 6 ++++++ src/main.rs | 18 ++++++------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/core/application/mod.rs b/src/core/application/mod.rs index 96bc627..906e1c6 100644 --- a/src/core/application/mod.rs +++ b/src/core/application/mod.rs @@ -191,6 +191,12 @@ impl Application { } } }); + + while self.is_running() { + slint::run_event_loop() + .unwrap_or_else(|e| log_util::log_error(format!("slint run_event_loop error: {:?}", e))); + self.clean(); + } } pub fn clean(&mut self) { diff --git a/src/main.rs b/src/main.rs index 97beac2..d82ebea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,19 +18,13 @@ fn main() { true } ) {return;} - + + // del tmp and .fd files file_util::del_useless_files() - .unwrap_or_else(|e| log_util::log_error(format!("del_useless_files error: {:?}", e))); // del tmp and .fd files + .unwrap_or_else(|e| log_util::log_error(format!("del_useless_files error: {:?}", e))); // start event loop - if let Ok(mut app) = Application::new() { - app.run(); - while app.is_running() { - slint::run_event_loop() - .unwrap_or_else(|e| log_util::log_error(format!("slint run_event_loop error: {:?}", e))); - app.clean(); - } - } else { - log_util::log_error("Application::new error".to_string()); - } + Application::new() + .map(|mut app| app.run()) + .unwrap_or_else(|_| log_util::log_error("Application::new error".to_string())); } \ No newline at end of file