fix: shutdown_flag 闭包借用/移动冲突(E0373/E0505)
setup 闭包借用 shutdown_flag 但要求 'static, on_window_event 又要 move 它。builder 链前各自 clone 出 setup_flag/event_flag, 两处闭包分别 move。
This commit is contained in:
@@ -218,6 +218,8 @@ pub fn run() {
|
|||||||
|
|
||||||
let shutdown_flag = Arc::new(AtomicBool::new(false));
|
let shutdown_flag = Arc::new(AtomicBool::new(false));
|
||||||
let ctrlc_flag = shutdown_flag.clone();
|
let ctrlc_flag = shutdown_flag.clone();
|
||||||
|
let setup_flag = shutdown_flag.clone();
|
||||||
|
let event_flag = shutdown_flag.clone();
|
||||||
|
|
||||||
ctrlc::set_handler(move || {
|
ctrlc::set_handler(move || {
|
||||||
info!("Ctrl+C received, shutting down gracefully...");
|
info!("Ctrl+C received, shutting down gracefully...");
|
||||||
@@ -238,7 +240,7 @@ pub fn run() {
|
|||||||
let app = tauri::Builder::default()
|
let app = tauri::Builder::default()
|
||||||
.plugin(hotswap)
|
.plugin(hotswap)
|
||||||
.plugin(tauri_plugin_shell::init())
|
.plugin(tauri_plugin_shell::init())
|
||||||
.setup(|app| {
|
.setup(move |app| {
|
||||||
info!("Initializing database...");
|
info!("Initializing database...");
|
||||||
|
|
||||||
let data_dir = app.path().app_data_dir().unwrap_or_else(|_| std::path::PathBuf::from("."));
|
let data_dir = app.path().app_data_dir().unwrap_or_else(|_| std::path::PathBuf::from("."));
|
||||||
@@ -257,7 +259,7 @@ pub fn run() {
|
|||||||
db: database,
|
db: database,
|
||||||
auth,
|
auth,
|
||||||
mcp,
|
mcp,
|
||||||
shutdown_flag: shutdown_flag.clone(),
|
shutdown_flag: setup_flag,
|
||||||
});
|
});
|
||||||
|
|
||||||
info!("Wardrobe app initialized, data dir: {:?}", data_dir);
|
info!("Wardrobe app initialized, data dir: {:?}", data_dir);
|
||||||
@@ -266,7 +268,7 @@ pub fn run() {
|
|||||||
.on_window_event(move |_window, event| {
|
.on_window_event(move |_window, event| {
|
||||||
if let tauri::WindowEvent::Destroyed = event {
|
if let tauri::WindowEvent::Destroyed = event {
|
||||||
info!("Window destroyed, shutting down gracefully...");
|
info!("Window destroyed, shutting down gracefully...");
|
||||||
shutdown_flag.store(true, Ordering::SeqCst);
|
event_flag.store(true, Ordering::SeqCst);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.invoke_handler(tauri::generate_handler![
|
.invoke_handler(tauri::generate_handler![
|
||||||
|
|||||||
Reference in New Issue
Block a user