Fix panic when wayland display connection breaks

Instead, terminate the thread and consider the clipboard dead. The
application can now gracefully deal with the situation.

Closes: #52
This commit is contained in:
Simon Hausmann 2024-02-19 10:23:54 +01:00 committed by GitHub
parent 858419b586
commit ee63d81a57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 9 deletions

View file

@ -42,9 +42,9 @@ impl MimeType {
}
}
impl ToString for MimeType {
fn to_string(&self) -> String {
String::from(ALLOWED_MIME_TYPES[*self as usize])
impl std::fmt::Display for MimeType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", ALLOWED_MIME_TYPES[*self as usize])
}
}

View file

@ -95,9 +95,7 @@ fn worker_impl(
WaylandSource::new(connection, event_queue).insert(loop_handle).unwrap();
loop {
event_loop.dispatch(None, &mut state).unwrap();
if state.exit {
if event_loop.dispatch(None, &mut state).is_err() || state.exit {
break;
}
}