@@ -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",
@@ -97,20 +97,6 @@ pub struct AppContext<Thread = ()> {
pub(crate) layout_id_buffer: Vec<LayoutId>, // We recycle this memory across layout requests.
}
-impl Deref for AppContext<MainThread> {
- type Target = AppContext<()>;
-
- fn deref(&self) -> &Self::Target {
- self
- }
-}
-
-impl DerefMut for AppContext<MainThread> {
- fn deref_mut(&mut self) -> &mut Self::Target {
- self
- }
-}
-
impl<Thread> AppContext<Thread> {
// TODO: Better names for these?
#[inline]
@@ -333,7 +319,10 @@ impl AppContext<MainThread> {
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
@@ -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
@@ -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| {