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:
parent
858419b586
commit
ee63d81a57
3 changed files with 5 additions and 9 deletions
|
|
@ -2,8 +2,6 @@
|
||||||
// application. For more details on what is going on, consult the
|
// application. For more details on what is going on, consult the
|
||||||
// `smithay-client-toolkit` examples.
|
// `smithay-client-toolkit` examples.
|
||||||
|
|
||||||
use std::convert::TryInto;
|
|
||||||
|
|
||||||
use sctk::compositor::{CompositorHandler, CompositorState};
|
use sctk::compositor::{CompositorHandler, CompositorState};
|
||||||
use sctk::output::{OutputHandler, OutputState};
|
use sctk::output::{OutputHandler, OutputState};
|
||||||
use sctk::reexports::calloop::{EventLoop, LoopHandle};
|
use sctk::reexports::calloop::{EventLoop, LoopHandle};
|
||||||
|
|
@ -23,7 +21,7 @@ use sctk::{
|
||||||
delegate_compositor, delegate_keyboard, delegate_output, delegate_registry, delegate_seat,
|
delegate_compositor, delegate_keyboard, delegate_output, delegate_registry, delegate_seat,
|
||||||
delegate_shm, delegate_xdg_shell, delegate_xdg_window, registry_handlers,
|
delegate_shm, delegate_xdg_shell, delegate_xdg_window, registry_handlers,
|
||||||
};
|
};
|
||||||
use smithay_clipboard::{self, Clipboard};
|
use smithay_clipboard::Clipboard;
|
||||||
|
|
||||||
const MIN_DIM_SIZE: usize = 256;
|
const MIN_DIM_SIZE: usize = 256;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,9 @@ impl MimeType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for MimeType {
|
impl std::fmt::Display for MimeType {
|
||||||
fn to_string(&self) -> String {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
String::from(ALLOWED_MIME_TYPES[*self as usize])
|
write!(f, "{}", ALLOWED_MIME_TYPES[*self as usize])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,9 +95,7 @@ fn worker_impl(
|
||||||
WaylandSource::new(connection, event_queue).insert(loop_handle).unwrap();
|
WaylandSource::new(connection, event_queue).insert(loop_handle).unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
event_loop.dispatch(None, &mut state).unwrap();
|
if event_loop.dispatch(None, &mut state).is_err() || state.exit {
|
||||||
|
|
||||||
if state.exit {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue