From 509d39ddea438a2e6c3ed4ee24473da0279839dd Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Tue, 12 Mar 2024 01:40:51 +0100 Subject: [PATCH] drain remaining signals --- hui/src/instance.rs | 3 +++ hui/src/signal.rs | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/hui/src/instance.rs b/hui/src/instance.rs index b23ed6c..c70f723 100644 --- a/hui/src/instance.rs +++ b/hui/src/instance.rs @@ -153,6 +153,9 @@ impl UiInstance { //first, drain and process the event queue self.input.update_state(&mut self.events); + //then, reset the (remaining) signals + self.signal.clear(); + //then, reset the draw commands std::mem::swap(&mut self.prev_draw_commands, &mut self.draw_commands); self.draw_commands.commands.clear(); diff --git a/hui/src/signal.rs b/hui/src/signal.rs index 238655a..89b7eb0 100644 --- a/hui/src/signal.rs +++ b/hui/src/signal.rs @@ -46,4 +46,10 @@ impl SignalStore { .drain(..) .map(|x| *x.downcast::().unwrap()) //unchecked? } + + /// Clear all signals + pub(crate) fn clear(&mut self) { + //XXX: should we clear the vecs instead? + self.sig.clear(); + } }