Skip to content

Commit

Permalink
Fix copy-paste on Windows (emilk#2120)
Browse files Browse the repository at this point in the history
Closes emilk#2109

Since arboard 3.0 you must absolutely not hold onto `arboard::Clipbaord`
longer than you are using it.

See 1Password/arboard#84
  • Loading branch information
emilk authored Oct 7, 2022
1 parent cd74c74 commit f61044c
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions crates/egui-winit/src/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ use std::os::raw::c_void;
/// If the "clipboard" feature is off, or we cannot connect to the OS clipboard,
/// then a fallback clipboard that just works works within the same app is used instead.
pub struct Clipboard {
#[cfg(all(feature = "arboard", not(target_os = "android")))]
arboard: Option<arboard::Clipboard>,

#[cfg(all(
any(
target_os = "linux",
Expand All @@ -28,8 +25,6 @@ impl Clipboard {
#[allow(unused_variables)]
pub fn new(#[allow(unused_variables)] wayland_display: Option<*mut c_void>) -> Self {
Self {
#[cfg(all(feature = "arboard", not(target_os = "android")))]
arboard: init_arboard(),
#[cfg(all(
any(
target_os = "linux",
Expand Down Expand Up @@ -67,7 +62,7 @@ impl Clipboard {
}

#[cfg(all(feature = "arboard", not(target_os = "android")))]
if let Some(clipboard) = &mut self.arboard {
if let Some(mut clipboard) = init_arboard() {
return match clipboard.get_text() {
Ok(text) => Some(text),
Err(err) => {
Expand Down Expand Up @@ -97,7 +92,7 @@ impl Clipboard {
}

#[cfg(all(feature = "arboard", not(target_os = "android")))]
if let Some(clipboard) = &mut self.arboard {
if let Some(mut clipboard) = init_arboard() {
if let Err(err) = clipboard.set_text(text) {
tracing::error!("Copy/Cut error: {}", err);
}
Expand Down

0 comments on commit f61044c

Please sign in to comment.