FIX: lib.rs — E0597 borrow, take child ra khoi lock truoc khi kill

This commit is contained in:
2026-08-08 10:12:21 +00:00
parent e978abf0e9
commit 4e4391b315
+8 -4
View File
@@ -28,14 +28,18 @@ pub fn run() {
.on_window_event(|window, event| { .on_window_event(|window, event| {
// 2. Terminate sidecar khi DAW window dong — tranh orphan process // 2. Terminate sidecar khi DAW window dong — tranh orphan process
if let tauri::WindowEvent::Destroyed = event { if let tauri::WindowEvent::Destroyed = event {
let state = window.state::<EngineProcess>(); // Lay child ra khoi lock, guard drop ngay tai day (trach E0597)
if let Ok(mut lock) = state.0.lock() { let child = window
if let Some(child) = lock.take() { .state::<EngineProcess>()
.0
.lock()
.ok()
.and_then(|mut lock| lock.take());
if let Some(child) = child {
let _ = child.kill(); let _ = child.kill();
println!("daw_engine sidecar terminated."); println!("daw_engine sidecar terminated.");
} }
} }
}
}) })
.run(tauri::generate_context!()) .run(tauri::generate_context!())
.expect("error while running tauri application"); .expect("error while running tauri application");