From 9ba97a9a2f014cac67b5ad94f960d79fb7c17ae6 Mon Sep 17 00:00:00 2001 From: lucasmerlin Date: Fri, 20 Sep 2024 09:08:44 +0200 Subject: [PATCH] Fix empty grids repeatedly requesting a discard (#5133) * Closes * [x] I have followed the instructions in the PR template This does cause a slight difference in the amount of space allocated by a empty grid, is this a problem? Before: image After: image --- crates/egui/src/grid.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/grid.rs b/crates/egui/src/grid.rs index 42296e36290..9b3a382ee23 100644 --- a/crates/egui/src/grid.rs +++ b/crates/egui/src/grid.rs @@ -262,7 +262,9 @@ impl GridLayout { } pub(crate) fn save(&self) { - if self.curr_state != self.prev_state { + // We need to always save state on the first frame, otherwise request_discard + // would be called repeatedly (see #5132) + if self.curr_state != self.prev_state || self.is_first_frame { self.curr_state.clone().store(&self.ctx, self.id); self.ctx.request_repaint(); }