fix(media): prevent process termination on Windows for close_mpv_process function

This commit is contained in:
4gray committed 2024-12-16 23:58:17 +01:00
1 parent 0bdb06c808
commit a4eeafe6cb
1 file changed
+2 -11
+2 -11
View File
@@ -125,6 +125,8 @@ pub async fn close_mpv_process<R: Runtime>(
process_id: u32,
app_handle: tauri::AppHandle<R>,
) -> Result<(), String> {
#[cfg(windows)]
return Err("Process termination is not supported on Windows".to_string());
if let Some(process) = MPV_PROCESSES.lock().unwrap().remove(&process_id) {
#[cfg(unix)]
{
@@ -133,17 +135,6 @@ pub async fn close_mpv_process<R: Runtime>(
}
}
#[cfg(windows)]
{
unsafe {
let handle = OpenProcess(PROCESS_TERMINATE, 0, process_id);
if !handle.is_null() {
TerminateProcess(handle, 1);
CloseHandle(handle);
}
}
}
// Updated event emission
app_handle
.emit("mpv-process-removed", process)