Replace unwrap() with a check and an error message
Browse files at this commit00806d1f082d19728381c5a35fc0c04edb71c8dcParent: 99506721 changed file +10 -3
- src/handlers/xdg_shell.rs +10 -3
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) = self | 161 | + let win_out = self |
| 162 | .niri | 162 | .niri |
| 163 | .layout | 163 | .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 | } |