Skip to content

Commit a211466

Browse files
author
mikachu2333
committed
remove useless clone
1 parent 8ba9c1d commit a211466

3 files changed

Lines changed: 8 additions & 10 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "SC_Starter"
3-
version = "2.7.3"
3+
version = "2.7.4"
44
edition = "2021"
55

66
[profile.release]

src/hotkeys.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ pub fn set_hotkeys(
5252
let key_groups = settings_collected.keys_collection;
5353
let mut hkm = HotkeyManager::new();
5454

55-
// 初始化启动应用程序的进程ID管理
56-
let launch_pid: Arc<Mutex<u32>> = Arc::new(Mutex::new(0));
57-
5855
let comp_clone = comp.clone();
5956
let scale_clone = scale.clone();
6057
let exe_path_clone = exe_path.clone();
@@ -80,13 +77,14 @@ pub fn set_hotkeys(
8077
panic!("{}", &temp);
8178
};
8279

83-
// 注册Launch快捷键
84-
let launch_pid_clone = Arc::clone(&launch_pid);
80+
// 初始化启动应用程序的进程ID管理
81+
let launch_pid: Arc<Mutex<u32>> = Arc::new(Mutex::new(0));
82+
// 注册Launch快捷键\
8583
let hotkey_launch = hkm.register(
8684
key_groups.get("launch_app").unwrap().vkey,
8785
&key_groups.get("launch_app").unwrap().mod_keys,
8886
move || {
89-
let current_pid = *launch_pid_clone.lock().unwrap();
87+
let current_pid = *launch_pid.lock().unwrap();
9088

9189
// 获取启动程序的文件名用于进程检测
9290
let process_name = launch
@@ -105,7 +103,7 @@ pub fn set_hotkeys(
105103
return;
106104
} else {
107105
// 进程已退出,重置PID
108-
*launch_pid_clone.lock().unwrap() = 0;
106+
*launch_pid.lock().unwrap() = 0;
109107
}
110108
}
111109
}
@@ -122,7 +120,7 @@ pub fn set_hotkeys(
122120
// 如果程序启动成功,记录PID并等待窗口创建后置顶
123121
if let Ok(child) = child {
124122
let pid = child.id();
125-
*launch_pid_clone.lock().unwrap() = pid;
123+
*launch_pid.lock().unwrap() = pid;
126124

127125
// 等待程序启动并创建窗口后置顶
128126
std::thread::sleep(T_SEC_1_2);

0 commit comments

Comments
 (0)