From 2ffc528986566cbdfd8edeb06a52d653c963d70c Mon Sep 17 00:00:00 2001 From: dignow Date: Tue, 1 Aug 2023 20:12:56 +0800 Subject: [PATCH] refact, win file clipboard enable Signed-off-by: dignow --- src/core_main.rs | 3 --- src/ui_session_interface.rs | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core_main.rs b/src/core_main.rs index cf66255ca..14dbadf68 100644 --- a/src/core_main.rs +++ b/src/core_main.rs @@ -149,7 +149,6 @@ pub fn core_main() -> Option> { } #[cfg(windows)] if !crate::platform::is_installed() && (_is_elevate || _is_run_as_system) { - clipboard::ContextSend::enable(true); crate::platform::elevate_or_run_as_system(click_setup, _is_elevate, _is_run_as_system); return None; } @@ -158,8 +157,6 @@ pub fn core_main() -> Option> { init_plugins(&args); log::info!("main start args:{:?}", args); if args.is_empty() || is_empty_uni_link(&args[0]) { - #[cfg(windows)] - clipboard::ContextSend::enable(true); std::thread::spawn(move || crate::start_server(false)); } else { #[cfg(windows)] diff --git a/src/ui_session_interface.rs b/src/ui_session_interface.rs index effd293a6..fc00c64c8 100644 --- a/src/ui_session_interface.rs +++ b/src/ui_session_interface.rs @@ -1185,6 +1185,10 @@ impl Session { #[tokio::main(flavor = "current_thread")] pub async fn io_loop(handler: Session) { + // It is ok to call this function multiple times. + #[cfg(target_os ="windows")] + clipboard::ContextSend::enable(true); + #[cfg(any(target_os = "android", target_os = "ios"))] let (sender, receiver) = mpsc::unbounded_channel::(); #[cfg(not(any(target_os = "android", target_os = "ios")))]