diff --git a/Cargo.lock b/Cargo.lock index d7b49e5798495917b5b41762bd0bfcc61d7a7410..a8aa299305f39c7b19e17d0ce2b788e6e0a81110 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -758,6 +758,17 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "backtrace-on-stack-overflow" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fd2d70527f3737a1ad17355e260706c1badebabd1fa06a7a053407380df841b" +dependencies = [ + "backtrace", + "libc", + "nix 0.23.2", +] + [[package]] name = "bae" version = "0.1.7" @@ -4692,6 +4703,19 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "nix" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" +dependencies = [ + "bitflags 1.3.2", + "cc", + "cfg-if 1.0.0", + "libc", + "memoffset 0.6.5", +] + [[package]] name = "nix" version = "0.24.3" @@ -7521,6 +7545,7 @@ name = "storybook2" version = "0.1.0" dependencies = [ "anyhow", + "backtrace-on-stack-overflow", "gpui3", "log", "rust-embed", diff --git a/crates/gpui3/src/app.rs b/crates/gpui3/src/app.rs index 1bbcc8c608769ddc3179de4ae55426762c2757b2..afbe875d3362ad5fafc9552b547d55ef0ff348fe 100644 --- a/crates/gpui3/src/app.rs +++ b/crates/gpui3/src/app.rs @@ -97,20 +97,6 @@ pub struct AppContext { pub(crate) layout_id_buffer: Vec, // We recycle this memory across layout requests. } -impl Deref for AppContext { - type Target = AppContext<()>; - - fn deref(&self) -> &Self::Target { - self - } -} - -impl DerefMut for AppContext { - fn deref_mut(&mut self) -> &mut Self::Target { - self - } -} - impl AppContext { // TODO: Better names for these? #[inline] @@ -333,7 +319,10 @@ impl AppContext { let id = self.windows.insert(None); let handle = WindowHandle::new(id); let mut window = Window::new(handle.into(), options, self); - let root_view = build_root_view(&mut WindowContext::mutable(self, &mut window)); + let root_view = build_root_view(&mut WindowContext::mutable( + self.downcast_mut(), + &mut window, + )); window.root_view.replace(root_view.into_any()); self.windows.get_mut(id).unwrap().replace(window); handle diff --git a/crates/storybook2/Cargo.toml b/crates/storybook2/Cargo.toml index d1a7c41965297dd608e84d0535639fe35601dbac..bd984c54c139aa264070b087f11a61f6bce0cac8 100644 --- a/crates/storybook2/Cargo.toml +++ b/crates/storybook2/Cargo.toml @@ -10,6 +10,8 @@ path = "src/storybook2.rs" [dependencies] anyhow.workspace = true +# TODO: Remove after diagnosing stack overflow. +backtrace-on-stack-overflow = "0.3.0" gpui3 = { path = "../gpui3" } log.workspace = true rust-embed.workspace = true diff --git a/crates/storybook2/src/storybook2.rs b/crates/storybook2/src/storybook2.rs index a9fbc050b7f181106d4832ab0dc4bd7052a9a7f8..3b341dbd537033e31499652ba3b06699001fe37b 100644 --- a/crates/storybook2/src/storybook2.rs +++ b/crates/storybook2/src/storybook2.rs @@ -14,6 +14,8 @@ mod workspace; // } fn main() { + unsafe { backtrace_on_stack_overflow::enable() }; + SimpleLogger::init(LevelFilter::Info, Default::default()).expect("could not initialize logger"); gpui3::App::production().run(|cx| {