Fix copy-paste on Windows (#2120)
Closes https://github.com/emilk/egui/issues/2109 Since arboard 3.0 you must absolutely not hold onto `arboard::Clipbaord` longer than you are using it. See https://github.com/1Password/arboard/issues/84
This commit is contained in:
parent
cd74c74f6f
commit
f61044cef7
1 changed files with 2 additions and 7 deletions
|
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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) => {
|
||||
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue