diff options
author | lucasmerlin <lucasmeurer96@gmail.com> | 2024-09-20 09:08:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-20 09:08:44 +0200 |
commit | 9ba97a9a2f014cac67b5ad94f960d79fb7c17ae6 (patch) | |
tree | 9e00e2ce919e21673805e906f722452d93d27150 | |
parent | 5cc35d22127be4dbe58c2f7f80340c3d041094e9 (diff) |
Fix empty grids repeatedly requesting a discard (#5133)
* Closes <https://github.com/emilk/egui/issues/5132>
* [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:
<img width="113" alt="image"
src="https://github.com/user-attachments/assets/88c9c1a8-2ab8-4b01-8d57-0eb0655fa0e4">
After:
<img width="101" alt="image"
src="https://github.com/user-attachments/assets/8e1c9d1b-54d6-43b9-9e37-2614dd90d6fe">
-rw-r--r-- | crates/egui/src/grid.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/crates/egui/src/grid.rs b/crates/egui/src/grid.rs index 42296e36..9b3a382e 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(); } |