1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 22:01:47 +03:00

avoid a panic during shutdown

This commit is contained in:
Wez Furlong 2021-05-07 18:13:41 -07:00
parent e81fb6e721
commit 453cfc1813
4 changed files with 33 additions and 6 deletions

View File

@ -525,7 +525,13 @@ impl WindowOps for Window {
where where
Self: Sized, Self: Sized,
{ {
Connection::with_window_inner(self.0, move |inner| { // If we're already on the correct thread, just queue it up
if let Some(conn) = Connection::get() {
let handle = match conn.window_by_id(self.0) {
Some(h) => h,
None => return,
};
let mut inner = handle.borrow_mut();
if let Some(window_view) = WindowView::get_this(unsafe { &**inner.view }) { if let Some(window_view) = WindowView::get_this(unsafe { &**inner.view }) {
window_view window_view
.inner .inner
@ -534,8 +540,20 @@ impl WindowOps for Window {
.try_send(WindowEvent::Notification(Box::new(t))) .try_send(WindowEvent::Notification(Box::new(t)))
.ok(); .ok();
} }
Ok(()) } else {
}); // Otherwise, get into that thread and write to the queue
Connection::with_window_inner(self.0, move |inner| {
if let Some(window_view) = WindowView::get_this(unsafe { &**inner.view }) {
window_view
.inner
.borrow()
.events
.try_send(WindowEvent::Notification(Box::new(t)))
.ok();
}
Ok(())
});
}
} }
fn close(&self) -> Future<()> { fn close(&self) -> Future<()> {

View File

@ -644,7 +644,10 @@ impl WindowOps for WaylandWindow {
{ {
// If we're already on the correct thread, just queue it up // If we're already on the correct thread, just queue it up
if let Some(conn) = Connection::get() { if let Some(conn) = Connection::get() {
let handle = conn.wayland().window_by_id(self.0).unwrap(); let handle = match conn.wayland().window_by_id(self.0) {
Some(h) => h,
None => return,
};
let inner = handle.borrow(); let inner = handle.borrow();
inner inner
.events .events

View File

@ -580,7 +580,10 @@ impl WindowOps for Window {
{ {
// If we're already on the correct thread, just queue it up // If we're already on the correct thread, just queue it up
if let Some(conn) = Connection::get() { if let Some(conn) = Connection::get() {
let handle = conn.get_window(self.0).unwrap(); let handle = match conn.get_window(self.0) {
Some(h) => h,
None => return,
};
let inner = handle.borrow_mut(); let inner = handle.borrow_mut();
inner inner
.events .events

View File

@ -932,7 +932,10 @@ impl WindowOps for XWindow {
{ {
// If we're already on the correct thread, just queue it up // If we're already on the correct thread, just queue it up
if let Some(conn) = Connection::get() { if let Some(conn) = Connection::get() {
let handle = conn.x11().window_by_id(self.0).unwrap(); let handle = match conn.x11().window_by_id(self.0) {
Some(h) => h,
None => return,
};
let inner = handle.lock().unwrap(); let inner = handle.lock().unwrap();
inner inner
.events .events