From 957ad6af90ea7e2ad397aa971d9ca8368f6ac3be Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 17 Jan 2021 10:24:58 -0800 Subject: [PATCH] windows: avoid panic on startup In 30b262c1c0a2cdf690feb7c4abe067dc452de38f I introduced an unwrap here. On Windows, this code can be called before we've set up opengl. Allow for that! --- wezterm-gui/src/gui/termwindow.rs | 35 ++++++++++++++----------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/wezterm-gui/src/gui/termwindow.rs b/wezterm-gui/src/gui/termwindow.rs index 3f82b9aca..29dbc7e2e 100644 --- a/wezterm-gui/src/gui/termwindow.rs +++ b/wezterm-gui/src/gui/termwindow.rs @@ -2245,28 +2245,25 @@ impl TermWindow { (size, *dimensions) }; - if let Err(err) = self - .render_state - .as_mut() - .unwrap() - .advise_of_window_size_change( + if let Some(render_state) = self.render_state.as_mut() { + if let Err(err) = render_state.advise_of_window_size_change( &self.render_metrics, dimensions.pixel_width, dimensions.pixel_height, - ) - { - log::error!( - "failed to advise of resize from {:?} -> {:?}: {:?}", - orig_dimensions, - dimensions, - err - ); - // Try to restore the original dimensions - self.dimensions = orig_dimensions; - // Avoid the inner resize below - scale_changed_cells.take(); - } else { - self.terminal_size = size; + ) { + log::error!( + "failed to advise of resize from {:?} -> {:?}: {:?}", + orig_dimensions, + dimensions, + err + ); + // Try to restore the original dimensions + self.dimensions = orig_dimensions; + // Avoid the inner resize below + scale_changed_cells.take(); + } else { + self.terminal_size = size; + } } let mux = Mux::get().unwrap();