rustdesk 2022-05-10 01:08:21 +08:00
parent 17a4cb6b5c
commit 711d7ed6cd
4 changed files with 16 additions and 3 deletions

View File

@ -642,3 +642,12 @@ fn get_env(name: &str, uid: &str) -> String {
"".to_owned() "".to_owned()
} }
} }
#[link(name = "gtk-3")]
extern "C" {
fn gtk_main_quit();
}
pub fn quit_gui() {
unsafe { gtk_main_quit() };
}

View File

@ -519,7 +519,7 @@ pub fn is_installed() -> bool {
false false
} }
fn quit_gui() { pub fn quit_gui() {
use cocoa::appkit::NSApp; use cocoa::appkit::NSApp;
unsafe { unsafe {
let () = msg_send!(NSApp(), terminate: nil); let () = msg_send!(NSApp(), terminate: nil);

View File

@ -1091,3 +1091,7 @@ oLink.Save
allow_err!(std::fs::remove_file(shortcut)); allow_err!(std::fs::remove_file(shortcut));
Ok(()) Ok(())
} }
pub fn quit_gui() {
unsafe { PostQuitMessage(0) };
}

View File

@ -95,7 +95,7 @@ impl ConnectionManager {
fn remove_connection(&self, id: i32) { fn remove_connection(&self, id: i32) {
self.write().unwrap().senders.remove(&id); self.write().unwrap().senders.remove(&id);
if self.read().unwrap().senders.len() == 0 { if self.read().unwrap().senders.len() == 0 {
std::process::exit(0); crate::platform::quit_gui();
} }
self.call("removeConnection", &make_args!(id)); self.call("removeConnection", &make_args!(id));
} }
@ -414,7 +414,7 @@ async fn start_ipc(cm: ConnectionManager) {
log::error!("Failed to start cm ipc server: {}", err); log::error!("Failed to start cm ipc server: {}", err);
} }
} }
std::process::exit(-1); crate::platform::quit_gui();
} }
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]