mirror of
https://github.com/alacritty/alacritty.git
synced 2025-07-31 22:03:40 -04:00
Passthrough potential errors for EventLoopSender
This commit is contained in:
parent
1991496eb1
commit
1bed41fc76
2 changed files with 34 additions and 6 deletions
|
@ -560,6 +560,6 @@ impl WindowContext {
|
||||||
impl Drop for WindowContext {
|
impl Drop for WindowContext {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// Shutdown the terminal's PTY.
|
// Shutdown the terminal's PTY.
|
||||||
self.notifier.0.send(Msg::Shutdown);
|
let _ = self.notifier.0.send(Msg::Shutdown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
use std::fmt::{self, Display, Formatter};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{self, ErrorKind, Read, Write};
|
use std::io::{self, ErrorKind, Read, Write};
|
||||||
use std::marker::Send;
|
use std::marker::Send;
|
||||||
|
@ -339,13 +340,40 @@ impl event::Notify for Notifier {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.0.send(Msg::Input(bytes));
|
let _ = self.0.send(Msg::Input(bytes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl event::OnResize for Notifier {
|
impl event::OnResize for Notifier {
|
||||||
fn on_resize(&mut self, window_size: WindowSize) {
|
fn on_resize(&mut self, window_size: WindowSize) {
|
||||||
self.0.send(Msg::Resize(window_size));
|
let _ = self.0.send(Msg::Resize(window_size));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum EventLoopSendError {
|
||||||
|
/// Error polling the event loop.
|
||||||
|
Io(io::Error),
|
||||||
|
|
||||||
|
/// Error sending a message to the event loop.
|
||||||
|
Send(mpsc::SendError<Msg>),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for EventLoopSendError {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
EventLoopSendError::Io(err) => err.fmt(f),
|
||||||
|
EventLoopSendError::Send(err) => err.fmt(f),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for EventLoopSendError {
|
||||||
|
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
||||||
|
match self {
|
||||||
|
EventLoopSendError::Io(err) => err.source(),
|
||||||
|
EventLoopSendError::Send(err) => err.source(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,9 +384,9 @@ pub struct EventLoopSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventLoopSender {
|
impl EventLoopSender {
|
||||||
pub fn send(&self, msg: Msg) {
|
pub fn send(&self, msg: Msg) -> Result<(), EventLoopSendError> {
|
||||||
let _ = self.sender.send(msg);
|
self.sender.send(msg).map_err(EventLoopSendError::Send)?;
|
||||||
let _ = self.poller.notify();
|
self.poller.notify().map_err(EventLoopSendError::Io)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue