Skip to content

Commit

Permalink
Fix empty grids repeatedly requesting a discard (#5133)
Browse files Browse the repository at this point in the history
* Closes <#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">
  • Loading branch information
lucasmerlin committed Sep 20, 2024
1 parent 5cc35d2 commit 9ba97a9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/egui/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 9ba97a9

Please sign in to comment.