Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Log an error when a scene fails to build
Antonio Scandurra5666e8301ead
diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rsindex f054552ea37..fbd83625a5b 100644--- a/crates/gpui/src/app.rs+++ b/crates/gpui/src/app.rs@@ -26,6 +26,7 @@ use anyhow::{anyhow, Context, Result};use parking_lot::Mutex;use postage::oneshot;use smol::prelude::*;+use util::ResultExt;use uuid::Uuid;pub use action::*;@@ -1179,12 +1180,6 @@ impl AppContext {}}- pub(crate) fn name_for_view(&self, window_id: usize, view_id: usize) -> Option<&str> {- self.views- .get(&(window_id, view_id))- .map(|view| view.ui_name())- }-pub fn all_action_names<'a>(&'a self) -> impl Iterator<Item = &'static str> + 'a {self.action_deserializers.keys().copied()}@@ -1448,7 +1443,9 @@ impl AppContext {}));let mut window = Window::new(window_id, platform_window, self, build_root_view);- let scene = WindowContext::mutable(self, &mut window, window_id).build_scene();+ let scene = WindowContext::mutable(self, &mut window, window_id)+ .build_scene()+ .expect("initial scene should not error");window.platform_window.present_scene(scene);window}@@ -1758,8 +1755,9 @@ impl AppContext {if let Some(mut invalidation) = cx.window.invalidation.take() {let appearance = cx.window.platform_window.appearance();cx.invalidate(&mut invalidation, appearance);- let scene = cx.build_scene();- cx.window.platform_window.present_scene(scene);+ if let Some(scene) = cx.build_scene().log_err() {+ cx.window.platform_window.present_scene(scene);+ }}});}@@ -1835,8 +1833,9 @@ impl AppContext {.extend(cx.window.rendered_views.keys().copied());cx.invalidate(&mut invalidation, cx.window.platform_window.appearance());cx.refreshing = true;- let scene = cx.build_scene();- cx.window.platform_window.present_scene(scene);+ if let Some(scene) = cx.build_scene().log_err() {+ cx.window.platform_window.present_scene(scene);+ }});}}diff --git a/crates/gpui/src/app/window.rs b/crates/gpui/src/app/window.rsindex 41358ed3741..c9008b551eb 100644--- a/crates/gpui/src/app/window.rs+++ b/crates/gpui/src/app/window.rs@@ -807,13 +807,13 @@ impl<'a: 'b, 'b> WindowContext<'a, 'b> {Ok(element)}- pub fn build_scene(&mut self) -> Scene {+ pub fn build_scene(&mut self) -> Result<Scene> {let window_size = self.window.platform_window.content_size();let scale_factor = self.window.platform_window.scale_factor();let root_view_id = self.window.root_view().id();let mut rendered_root = self.window.rendered_views.remove(&root_view_id).unwrap();- rendered_root.layout(SizeConstraint::strict(window_size), self);+ rendered_root.layout(SizeConstraint::strict(window_size), self)?;let mut scene_builder = SceneBuilder::new(scale_factor);rendered_root.paint(@@ -821,7 +821,7 @@ impl<'a: 'b, 'b> WindowContext<'a, 'b> {Vector2F::zero(),RectF::from_points(Vector2F::zero(), window_size),self,- );+ )?;self.window.rendered_views.insert(root_view_id, rendered_root);@@ -837,7 +837,7 @@ impl<'a: 'b, 'b> WindowContext<'a, 'b> {}}- scene+ Ok(scene)}pub fn rect_for_text_range(&self, range_utf16: Range<usize>) -> Option<RectF> {