forge
Explore
Log in

Don't you dare go Hollow

Replace unwrap() with a check and an error message

Browse files at this commit

00806d1f082d19728381c5a35fc0c04edb71c8dcIvan MolodetskikhParent: 9950672
I just crashed here somehow.
src/handlers/xdg_shell.rsmodified+10 -3
@@ -158,11 +158,18 @@ impl XdgShellHandler for State {
158 return;158 return;
159 }159 }
160 160
161- let (window, output) = self161+ let win_out = self
162 .niri162 .niri
163 .layout163 .layout
164- .find_window_and_output(surface.wl_surface())164+ .find_window_and_output(surface.wl_surface());
165- .unwrap();165+
166+ let Some((window, output)) = win_out else {
167+ // I have no idea how this can happen, but I saw it happen once, in a weird interaction
168+ // involving laptop going to sleep and resuming.
169+ error!("toplevel missing from both unmapped_windows and layout");
170+ return;
171+ };
172+
166 self.niri.layout.remove_window(&window);173 self.niri.layout.remove_window(&window);
167 self.niri.queue_redraw(output);174 self.niri.queue_redraw(output);
168 }175 }