From 4b91de3d59767329696810502b8130fa7c100d83 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Tue, 20 Oct 2020 23:19:13 +0300 Subject: [PATCH] state: remove overlay widgets on ComponentKill events --- src/state.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/state.rs b/src/state.rs index 1419ce29..b6cc736b 100644 --- a/src/state.rs +++ b/src/state.rs @@ -1174,14 +1174,16 @@ impl State { self.display_messages_pos = self.display_messages.len() - 1; self.redraw(); } + UIEvent::ComponentKill(ref id) if self.overlay.iter().any(|c| c.id() == *id) => { + let pos = self.overlay.iter().position(|c| c.id() == *id).unwrap(); + self.overlay.remove(pos); + } UIEvent::FinishedUIDialog(ref id, ref mut results) if self.overlay.iter().any(|c| c.id() == *id) => { if let Some(ref mut action @ Some(_)) = results.downcast_mut::>() { self.exec_command(action.take().unwrap()); - let pos = self.overlay.iter().position(|c| c.id() == *id).unwrap(); - self.overlay.remove(pos); return; } }