1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 05:12:40 +03:00

fix xcb raising a fatal error when closing a window

The rust xcb bindings seem to have gotten more strict in 1.x;
previously we might generate two DestroyWindow calls for the same
window when closing one and things were fine, but now the second
call generates a protocol error which has the effect of terminating
the program.

This commit ensures that we only generate a single DestroyWindow
call by zeroing out the saved window_id after we emit it.

refs: #1974
This commit is contained in:
Wez Furlong 2022-05-11 06:52:52 -07:00
parent 3afa00a56c
commit cd623dffa8

View File

@ -77,6 +77,7 @@ pub(crate) struct XWindowInner {
impl Drop for XWindowInner {
fn drop(&mut self) {
if self.window_id != xcb::x::Window::none() {
if let Some(conn) = self.conn.upgrade() {
conn.send_request(&xcb::x::DestroyWindow {
window: self.window_id,
@ -84,6 +85,7 @@ impl Drop for XWindowInner {
}
}
}
}
unsafe impl HasRawWindowHandle for XWindowInner {
fn raw_window_handle(&self) -> RawWindowHandle {
@ -1038,6 +1040,10 @@ impl XWindowInner {
self.conn().conn().send_request(&xcb::x::DestroyWindow {
window: self.window_id,
});
// Ensure that we don't try to destroy the window twice,
// otherwise the rust xcb bindings will generate a
// fatal error!
self.window_id = xcb::x::Window::none();
}
fn hide(&mut self) {}
fn show(&mut self) {