From 7cef4a5d405034892ce998d5f83169aa80fbeb5a Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Tue, 7 Feb 2023 13:39:48 -0500 Subject: [PATCH] Allocate theme struct directly into the heap Co-Authored-By: Max Brunsfeld Co-Authored-By: Mikayla Maki --- crates/theme/src/theme_registry.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/theme/src/theme_registry.rs b/crates/theme/src/theme_registry.rs index cc5e5490afc1d18ae200d01059a2b734cfb1615b..d47625289bfd693201c0ea18de1e0fb216cebae2 100644 --- a/crates/theme/src/theme_registry.rs +++ b/crates/theme/src/theme_registry.rs @@ -55,13 +55,13 @@ impl ThemeRegistry { .load(&asset_path) .with_context(|| format!("failed to load theme file {}", asset_path))?; - let mut theme: Theme = fonts::with_font_cache(self.font_cache.clone(), || { + // Allocate into the heap directly, the Theme struct is too large to fit in the stack. + let mut theme: Arc = fonts::with_font_cache(self.font_cache.clone(), || { serde_path_to_error::deserialize(&mut serde_json::Deserializer::from_slice(&theme_json)) })?; // Reset name to be the file path, so that we can use it to access the stored themes - theme.meta.name = name.into(); - let theme = Arc::new(theme); + Arc::get_mut(&mut theme).unwrap().meta.name = name.into(); self.themes.lock().insert(name.to_string(), theme.clone()); Ok(theme) }