Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
gpui: Box `Window` instances (#40733)
Lukas Wirthed822330301a
diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rsindex a5f53c2dad1..d4bd7798187 100644--- a/crates/gpui/src/app.rs+++ b/crates/gpui/src/app.rs@@ -553,7 +553,7 @@ pub struct App {pub(crate) entities: EntityMap,pub(crate) window_update_stack: Vec<WindowId>,pub(crate) new_entity_observers: SubscriberSet<TypeId, NewEntityListener>,- pub(crate) windows: SlotMap<WindowId, Option<Window>>,+ pub(crate) windows: SlotMap<WindowId, Option<Box<Window>>>,pub(crate) window_handles: FxHashMap<WindowId, AnyWindowHandle>,pub(crate) focus_handles: Arc<FocusMap>,pub(crate) keymap: Rc<RefCell<Keymap>>,@@ -964,7 +964,7 @@ impl App {clear.clear();cx.window_handles.insert(id, window.handle);- cx.windows.get_mut(id).unwrap().replace(window);+ cx.windows.get_mut(id).unwrap().replace(Box::new(window));Ok(handle)}Err(e) => {@@ -1239,7 +1239,7 @@ impl App {.windows.values().filter_map(|window| {- let window = window.as_ref()?;+ let window = window.as_deref()?;window.invalidator.is_dirty().then_some(window.handle)}).collect::<Vec<_>>()@@ -1320,7 +1320,7 @@ impl App {fn apply_refresh_effect(&mut self) {for window in self.windows.values_mut() {- if let Some(window) = window.as_mut() {+ if let Some(window) = window.as_deref_mut() {window.refreshing = true;window.invalidator.set_dirty(true);}@@ -2199,7 +2199,7 @@ impl AppContext for App {.windows.get(window.id).context("window not found")?- .as_ref()+ .as_deref().expect("attempted to read a window that is already on the stack");let root_view = window.root.clone().unwrap();diff --git a/crates/gpui/src/app/test_context.rs b/crates/gpui/src/app/test_context.rsindex 2e24c3ba195..cba6de6e319 100644--- a/crates/gpui/src/app/test_context.rs+++ b/crates/gpui/src/app/test_context.rs@@ -455,7 +455,7 @@ impl TestAppContext {.windows.get_mut(window.id).unwrap()- .as_mut()+ .as_deref_mut().unwrap().platform_window.as_test()diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rsindex 5534a4a8ddf..6855874bae2 100644--- a/crates/gpui/src/window.rs+++ b/crates/gpui/src/window.rs@@ -4718,7 +4718,7 @@ impl<V: 'static + Render> WindowHandle<V> {.get(self.id).and_then(|window| {window- .as_ref()+ .as_deref().and_then(|window| window.root.clone()).map(|root_view| root_view.downcast::<V>())})