mirror of
https://github.com/wez/wezterm.git
synced 2024-11-10 15:04:32 +03:00
avoid race condition when closing last window in a workspace
This isn't ideal, but it is better than previously: we would close the window and before the Drop impl had updated the list of known windows, we'd try to re-assign that window to another mux window in a different workspace, but it would never appear because the window was closed. refs: https://github.com/wez/wezterm/issues/1531
This commit is contained in:
parent
093b448624
commit
39c2da3bdf
@ -178,8 +178,8 @@ impl GuiFrontEnd {
|
||||
self.known_windows.borrow_mut().push(window);
|
||||
}
|
||||
|
||||
pub fn forget_known_window(&self, window: Window) {
|
||||
self.known_windows.borrow_mut().retain(|w| *w != window);
|
||||
pub fn forget_known_window(&self, window: &Window) {
|
||||
self.known_windows.borrow_mut().retain(|w| w != window);
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ pub fn record_known_window(window: Window) {
|
||||
});
|
||||
}
|
||||
|
||||
pub fn forget_known_window(window: Window) {
|
||||
pub fn forget_known_window(window: &Window) {
|
||||
FRONT_END.with(|f| {
|
||||
f.borrow_mut()
|
||||
.as_mut()
|
||||
|
@ -346,6 +346,7 @@ impl TermWindow {
|
||||
// Immediately kill the tabs and allow the window to close
|
||||
mux.kill_window(self.mux_window_id);
|
||||
window.close();
|
||||
crate::frontend::forget_known_window(window);
|
||||
}
|
||||
WindowCloseConfirmation::AlwaysPrompt => {
|
||||
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
|
||||
@ -353,6 +354,7 @@ impl TermWindow {
|
||||
None => {
|
||||
mux.kill_window(self.mux_window_id);
|
||||
window.close();
|
||||
crate::frontend::forget_known_window(window);
|
||||
return;
|
||||
}
|
||||
};
|
||||
@ -365,6 +367,7 @@ impl TermWindow {
|
||||
if can_close {
|
||||
mux.kill_window(self.mux_window_id);
|
||||
window.close();
|
||||
crate::frontend::forget_known_window(window);
|
||||
return;
|
||||
}
|
||||
let window = self.window.clone().unwrap();
|
||||
@ -846,6 +849,7 @@ impl TermWindow {
|
||||
if gl.is_context_lost() {
|
||||
log::error!("opengl context was lost; should reinit");
|
||||
window.close();
|
||||
crate::frontend::forget_known_window(window);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -961,6 +965,7 @@ impl TermWindow {
|
||||
MuxNotification::WindowRemoved(window_id) => {
|
||||
if window_id == self.mux_window_id {
|
||||
window.close();
|
||||
crate::frontend::forget_known_window(window);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
@ -995,7 +1000,6 @@ impl TermWindow {
|
||||
}
|
||||
};
|
||||
self.update_title();
|
||||
|
||||
window.invalidate();
|
||||
}
|
||||
}
|
||||
@ -2543,7 +2547,7 @@ impl TermWindow {
|
||||
impl Drop for TermWindow {
|
||||
fn drop(&mut self) {
|
||||
if let Some(window) = self.window.take() {
|
||||
crate::frontend::forget_known_window(window);
|
||||
crate::frontend::forget_known_window(&window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user