Dropping the clipboard does not close the connection leading to "Maximum number of clients reached"
Closed this issue · 2 comments
mathieulj commented
The background thread ignores the channel closed error and keeps running indefinitely without shutting down the connection so dropping the clipboard does not close the connection.
Simple reproduction:
use x11_clipboard::error::Error;
use x11_clipboard::Clipboard;
pub fn paste_to_clipboard(content: &str) -> Result<(), Error> {
let clipboard = Clipboard::new()?;
clipboard.store(
clipboard.setter.atoms.primary,
clipboard.setter.atoms.utf8_string,
content,
)?;
clipboard.store(
clipboard.setter.atoms.clipboard,
clipboard.setter.atoms.utf8_string,
content,
)?;
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn should_work_but_does_not() -> Result<(), Error> {
for i in 0..1000 {
paste_to_clipboard(&format!("I have told you {} times!", i))?;
}
Ok(())
}
}
quininer commented
Good catch.