make clipboard dropped after no sub

This commit is contained in:
rustdesk
2024-07-01 00:24:23 +08:00
parent 84b5cd70ed
commit cd73368cb9
2 changed files with 14 additions and 12 deletions

View File

@@ -4,12 +4,18 @@ pub use crate::common::{
CONTENT,
};
#[derive(Default)]
struct State {
ctx: Option<ClipboardContext>,
}
impl Default for State {
fn default() -> Self {
impl super::service::Reset for State {
fn reset(&mut self) {
*CONTENT.lock().unwrap() = Default::default();
self.ctx = None;
}
fn init(&mut self) {
let ctx = match ClipboardContext::new(true) {
Ok(ctx) => Some(ctx),
Err(err) => {
@@ -17,13 +23,7 @@ impl Default for State {
None
}
};
Self { ctx }
}
}
impl super::service::Reset for State {
fn reset(&mut self) {
*CONTENT.lock().unwrap() = Default::default();
self.ctx = ctx;
}
}