From f789159a4a5675ffa197b2a528b6ba0aaaa9693a Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 19 Apr 2022 21:28:45 +0200 Subject: [PATCH] Don't persist Grid sizes A) there are potentially a lot of Grids, using up a lot of space (and therefore serialization time). B) if the code changes, the grid should also change, and not remember old sizes --- egui/src/grid.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/egui/src/grid.rs b/egui/src/grid.rs index c903c157..65ff0cf5 100644 --- a/egui/src/grid.rs +++ b/egui/src/grid.rs @@ -1,7 +1,6 @@ use crate::*; #[derive(Clone, Debug, Default, PartialEq)] -#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub(crate) struct State { col_widths: Vec, row_heights: Vec, @@ -9,11 +8,14 @@ pub(crate) struct State { impl State { pub fn load(ctx: &Context, id: Id) -> Option { - ctx.data().get_persisted(id) + ctx.data().get_temp(id) } pub fn store(self, ctx: &Context, id: Id) { - ctx.data().insert_persisted(id, self); + // We don't persist Grids, because + // A) there are potentially a lot of them, using up a lot of space (and therefore serialization time) + // B) if the code changes, the grid _should_ change, and not remember old sizes + ctx.data().insert_temp(id, self); } fn set_min_col_width(&mut self, col: usize, width: f32) {