Fix stack overflow by removing Deref
and DerefMut
impls
This commit is contained in:
parent
8cac89d17c
commit
3b38641f98
4 changed files with 33 additions and 15 deletions
25
Cargo.lock
generated
25
Cargo.lock
generated
|
@ -758,6 +758,17 @@ dependencies = [
|
||||||
"rustc-demangle",
|
"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]]
|
[[package]]
|
||||||
name = "bae"
|
name = "bae"
|
||||||
version = "0.1.7"
|
version = "0.1.7"
|
||||||
|
@ -4692,6 +4703,19 @@ dependencies = [
|
||||||
"winapi 0.3.9",
|
"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]]
|
[[package]]
|
||||||
name = "nix"
|
name = "nix"
|
||||||
version = "0.24.3"
|
version = "0.24.3"
|
||||||
|
@ -7521,6 +7545,7 @@ name = "storybook2"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"backtrace-on-stack-overflow",
|
||||||
"gpui3",
|
"gpui3",
|
||||||
"log",
|
"log",
|
||||||
"rust-embed",
|
"rust-embed",
|
||||||
|
|
|
@ -97,20 +97,6 @@ pub struct AppContext<Thread = ()> {
|
||||||
pub(crate) layout_id_buffer: Vec<LayoutId>, // We recycle this memory across layout requests.
|
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> {
|
impl<Thread> AppContext<Thread> {
|
||||||
// TODO: Better names for these?
|
// TODO: Better names for these?
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -333,7 +319,10 @@ impl AppContext<MainThread> {
|
||||||
let id = self.windows.insert(None);
|
let id = self.windows.insert(None);
|
||||||
let handle = WindowHandle::new(id);
|
let handle = WindowHandle::new(id);
|
||||||
let mut window = Window::new(handle.into(), options, self);
|
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());
|
window.root_view.replace(root_view.into_any());
|
||||||
self.windows.get_mut(id).unwrap().replace(window);
|
self.windows.get_mut(id).unwrap().replace(window);
|
||||||
handle
|
handle
|
||||||
|
|
|
@ -10,6 +10,8 @@ path = "src/storybook2.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
# TODO: Remove after diagnosing stack overflow.
|
||||||
|
backtrace-on-stack-overflow = "0.3.0"
|
||||||
gpui3 = { path = "../gpui3" }
|
gpui3 = { path = "../gpui3" }
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
rust-embed.workspace = true
|
rust-embed.workspace = true
|
||||||
|
|
|
@ -14,6 +14,8 @@ mod workspace;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
unsafe { backtrace_on_stack_overflow::enable() };
|
||||||
|
|
||||||
SimpleLogger::init(LevelFilter::Info, Default::default()).expect("could not initialize logger");
|
SimpleLogger::init(LevelFilter::Info, Default::default()).expect("could not initialize logger");
|
||||||
|
|
||||||
gpui3::App::production().run(|cx| {
|
gpui3::App::production().run(|cx| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue