rustdesk 2022-02-06 18:19:06 +08:00
parent 3ec69b6d97
commit 809c220eaf
4 changed files with 22 additions and 6 deletions

2
Cargo.lock generated
View File

@ -3503,7 +3503,7 @@ dependencies = [
[[package]]
name = "sciter-rs"
version = "0.5.57"
source = "git+https://github.com/open-trade/rust-sciter?branch=dyn#4cd10f985e76d64fbf3438ffe7532489936f489a"
source = "git+https://github.com/open-trade/rust-sciter?branch=dyn#82025b9ba77d5ae14543009444033036dbe25917"
dependencies = [
"lazy_static",
"libc",

View File

@ -22,6 +22,11 @@ use std::{
pub type Childs = Arc<Mutex<(bool, HashMap<(String, String), Child>)>>;
lazy_static::lazy_static! {
// stupid workaround for https://sciter.com/forums/topic/crash-on-latest-tis-mac-sdk-sometimes/
static ref STUPID_VALUES: Mutex<Vec<Arc<Vec<Value>>>> = Default::default();
}
#[derive(Default)]
struct UI(
Childs,
@ -811,3 +816,10 @@ fn check_connect_status(
std::thread::spawn(move || check_connect_status_(reconnect, cloned, cloned_options));
(status, options)
}
// sacrifice some memory
pub fn value_crash_workaround(values: &[Value]) -> Arc<Vec<Value>> {
let persist = Arc::new(values.to_vec());
STUPID_VALUES.lock().unwrap().push(persist.clone());
persist
}

View File

@ -61,7 +61,7 @@ impl ConnectionManager {
fn call(&self, func: &str, args: &[Value]) {
let r = self.read().unwrap();
if let Some(ref e) = r.root {
allow_err!(e.call_method(func, args));
allow_err!(e.call_method(func, &super::value_crash_workaround(args)[..]));
}
}

View File

@ -1066,7 +1066,7 @@ impl Handler {
fn call(&self, func: &str, args: &[Value]) {
let r = self.read().unwrap();
if let Some(ref e) = r.element {
allow_err!(e.call_method(func, args));
allow_err!(e.call_method(func, &super::value_crash_workaround(args)[..]));
}
}
@ -1605,7 +1605,7 @@ impl Remote {
if !(self.handler.is_file_transfer()
|| self.handler.is_port_forward()
|| !unsafe { SERVER_CLIPBOARD_ENABLED }
|| !unsafe { SERVER_KEYBOARD_ENABLED }
|| !unsafe { SERVER_KEYBOARD_ENABLED }
|| self.handler.lc.read().unwrap().disable_clipboard)
{
let txt = self.old_clipboard.lock().unwrap().clone();
@ -1681,12 +1681,16 @@ impl Remote {
log::info!("Change permission {:?} -> {}", p.permission, p.enabled);
match p.permission.enum_value_or_default() {
Permission::Keyboard => {
unsafe { SERVER_KEYBOARD_ENABLED = p.enabled; }
unsafe {
SERVER_KEYBOARD_ENABLED = p.enabled;
}
self.handler
.call("setPermission", &make_args!("keyboard", p.enabled));
}
Permission::Clipboard => {
unsafe { SERVER_CLIPBOARD_ENABLED = p.enabled; }
unsafe {
SERVER_CLIPBOARD_ENABLED = p.enabled;
}
self.handler
.call("setPermission", &make_args!("clipboard", p.enabled));
}