mirror of
https://github.com/wez/wezterm.git
synced 2024-12-24 13:52:55 +03:00
avoid a panic during shutdown
This commit is contained in:
parent
e81fb6e721
commit
453cfc1813
@ -525,7 +525,13 @@ impl WindowOps for Window {
|
||||
where
|
||||
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 }) {
|
||||
window_view
|
||||
.inner
|
||||
@ -534,8 +540,20 @@ impl WindowOps for Window {
|
||||
.try_send(WindowEvent::Notification(Box::new(t)))
|
||||
.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<()> {
|
||||
|
@ -644,7 +644,10 @@ impl WindowOps for WaylandWindow {
|
||||
{
|
||||
// If we're already on the correct thread, just queue it up
|
||||
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();
|
||||
inner
|
||||
.events
|
||||
|
@ -580,7 +580,10 @@ impl WindowOps for Window {
|
||||
{
|
||||
// If we're already on the correct thread, just queue it up
|
||||
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();
|
||||
inner
|
||||
.events
|
||||
|
@ -932,7 +932,10 @@ impl WindowOps for XWindow {
|
||||
{
|
||||
// If we're already on the correct thread, just queue it up
|
||||
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();
|
||||
inner
|
||||
.events
|
||||
|
Loading…
Reference in New Issue
Block a user