small tweak

This commit is contained in:
rustdesk 2022-04-28 12:10:14 +08:00
parent 0b6155bab8
commit de44e45ed6
2 changed files with 12 additions and 3 deletions

View File

@ -145,7 +145,7 @@ pub fn is_installed_daemon(prompt: bool) -> bool {
.args(&["load", "-w", &agent_plist_file]) .args(&["load", "-w", &agent_plist_file])
.status() .status()
.ok(); .ok();
std::process::exit(0); quit_gui();
} }
} }
} }
@ -183,6 +183,8 @@ pub fn uninstall() -> bool {
); );
if uninstalled { if uninstalled {
crate::ipc::set_option("stop-service", "Y"); crate::ipc::set_option("stop-service", "Y");
// leave ipc a little time
std::thread::sleep(std::time::Duration::from_millis(300));
std::process::Command::new("launchctl") std::process::Command::new("launchctl")
.args(&["remove", &format!("{}_server", crate::get_full_name())]) .args(&["remove", &format!("{}_server", crate::get_full_name())])
.status() .status()
@ -202,7 +204,7 @@ pub fn uninstall() -> bool {
)) ))
.spawn() .spawn()
.ok(); .ok();
std::process::exit(0); quit_gui();
} }
} }
} }
@ -517,3 +519,10 @@ pub fn is_installed() -> bool {
} }
false false
} }
fn quit_gui() {
use cocoa::appkit::NSApp;
unsafe {
let () = msg_send!(NSApp(), terminate: nil);
};
}

View File

@ -339,7 +339,7 @@ async fn sync_and_watch_config_dir() {
if std::env::args().len() == 2 && std::env::args().nth(1) == Some("--server".to_owned()) { if std::env::args().len() == 2 && std::env::args().nth(1) == Some("--server".to_owned()) {
30 30
} else { } else {
1 3
}; };
log::debug!("#tries of ipc service connection: {}", tries); log::debug!("#tries of ipc service connection: {}", tries);
for i in 1..=tries { for i in 1..=tries {