Checkpoint: Narrow down error

This commit is contained in:
Marshall Bowers 2023-11-02 12:47:06 -04:00
parent 66e4d75e6f
commit 0e1d2fdf21
8 changed files with 37 additions and 31 deletions

View file

@ -47,10 +47,10 @@ impl AppCell {
AppRef(self.app.borrow())
}
pub fn borrow_mut(&self, label: &str) -> AppRefMut {
pub fn borrow_mut(&self) -> AppRefMut {
let thread_id = std::thread::current().id();
eprintln!(">>> borrowing {thread_id:?}: {label}");
eprintln!(">>> borrowing {thread_id:?}");
AppRefMut(self.app.borrow_mut())
}
}
@ -85,7 +85,7 @@ impl App {
let platform = self.0.borrow().platform.clone();
platform.run(Box::new(move || {
dbg!("run callback");
let cx = &mut *this.borrow_mut("app::borrow_mut");
let cx = &mut *this.borrow_mut();
on_finish_launching(cx);
}));
}
@ -99,7 +99,7 @@ impl App {
let this = Rc::downgrade(&self.0);
self.0.borrow().platform.on_open_urls(Box::new(move |urls| {
if let Some(app) = this.upgrade() {
callback(urls, &mut *app.borrow_mut("app.rs::on_open_urls"));
callback(urls, &mut *app.borrow_mut());
}
}));
self
@ -110,11 +110,14 @@ impl App {
F: 'static + FnMut(&mut AppContext),
{
let this = Rc::downgrade(&self.0);
self.0.borrow_mut("app.rs::on_reopen").platform.on_reopen(Box::new(move || {
if let Some(app) = this.upgrade() {
callback(&mut app.borrow_mut("app.rs::on_reopen(callback)"));
}
}));
self.0
.borrow_mut()
.platform
.on_reopen(Box::new(move || {
if let Some(app) = this.upgrade() {
callback(&mut app.borrow_mut());
}
}));
self
}

View file

@ -29,7 +29,7 @@ impl Context for AsyncAppContext {
.upgrade()
.ok_or_else(|| anyhow!("app was released"))?;
dbg!("BUILD MODEL A");
let mut app = app.borrow_mut("gpui2/async_context.rs::build_model");
let mut app = app.borrow_mut();
Ok(app.build_model(build_model))
}
@ -43,7 +43,7 @@ impl Context for AsyncAppContext {
.upgrade()
.ok_or_else(|| anyhow!("app was released"))?;
dbg!("UPDATE MODEL B");
let mut app = app.borrow_mut("gpui2/async_context.rs::update_model");
let mut app = app.borrow_mut();
Ok(app.update_model(handle, update))
}
@ -53,7 +53,7 @@ impl Context for AsyncAppContext {
{
let app = self.app.upgrade().context("app was released")?;
dbg!("UPDATE WINDOW C");
let mut lock = app.borrow_mut("gpui2/async_context::update_window");
let mut lock = app.borrow_mut();
lock.update_window(window, f)
}
}
@ -65,7 +65,7 @@ impl AsyncAppContext {
.upgrade()
.ok_or_else(|| anyhow!("app was released"))?;
dbg!("REFRESH");
let mut lock = app.borrow_mut("async_context.rs::refresh");
let mut lock = app.borrow_mut();
lock.refresh();
Ok(())
}
@ -83,7 +83,7 @@ impl AsyncAppContext {
.app
.upgrade()
.ok_or_else(|| anyhow!("app was released"))?;
let mut lock = app.borrow_mut("async_context.rs::update");
let mut lock = app.borrow_mut();
Ok(f(&mut *lock))
}
@ -99,7 +99,7 @@ impl AsyncAppContext {
.app
.upgrade()
.ok_or_else(|| anyhow!("app was released"))?;
let mut lock = app.borrow_mut("open_window");
let mut lock = app.borrow_mut();
Ok(lock.open_window(options, build_root_view))
}
@ -116,7 +116,7 @@ impl AsyncAppContext {
.app
.upgrade()
.ok_or_else(|| anyhow!("app was released"))?;
let app = app.borrow_mut("has_global");
let app = app.borrow_mut();
Ok(app.has_global::<G>())
}
@ -126,7 +126,7 @@ impl AsyncAppContext {
.upgrade()
.ok_or_else(|| anyhow!("app was released"))?;
dbg!("read global");
let app = app.borrow_mut("async_context.rs::read_global");
let app = app.borrow_mut();
Ok(read(app.global(), &app))
}
@ -136,7 +136,7 @@ impl AsyncAppContext {
) -> Option<R> {
let app = self.app.upgrade()?;
dbg!("try read global");
let app = app.borrow_mut("async_context.rs::try_read_global");
let app = app.borrow_mut();
Some(read(app.try_global()?, &app))
}
@ -149,7 +149,7 @@ impl AsyncAppContext {
.upgrade()
.ok_or_else(|| anyhow!("app was released"))?;
dbg!("update global");
let mut app = app.borrow_mut("async_context.rs::update_global");
let mut app = app.borrow_mut();
Ok(app.update_global(update))
}
}

View file

@ -24,7 +24,7 @@ impl Context for TestAppContext {
where
T: 'static,
{
let mut app = self.app.borrow_mut("test_context.rs::build_model");
let mut app = self.app.borrow_mut();
app.build_model(build_model)
}
@ -33,7 +33,7 @@ impl Context for TestAppContext {
handle: &Model<T>,
update: impl FnOnce(&mut T, &mut ModelContext<'_, T>) -> R,
) -> Self::Result<R> {
let mut app = self.app.borrow_mut("test_context::update_model");
let mut app = self.app.borrow_mut();
app.update_model(handle, update)
}
@ -41,7 +41,7 @@ impl Context for TestAppContext {
where
F: FnOnce(AnyView, &mut WindowContext<'_>) -> T,
{
let mut lock = self.app.borrow_mut("test_context::update_window");
let mut lock = self.app.borrow_mut();
lock.update_window(window, f)
}
}
@ -65,11 +65,11 @@ impl TestAppContext {
}
pub fn quit(&self) {
self.app.borrow_mut("test_context.rs::quit").quit();
self.app.borrow_mut().quit();
}
pub fn refresh(&mut self) -> Result<()> {
let mut app = self.app.borrow_mut("test_context.rs::refresh");
let mut app = self.app.borrow_mut();
app.refresh();
Ok(())
}
@ -83,7 +83,7 @@ impl TestAppContext {
}
pub fn update<R>(&self, f: impl FnOnce(&mut AppContext) -> R) -> R {
let mut cx = self.app.borrow_mut("test_context::update");
let mut cx = self.app.borrow_mut();
cx.update(f)
}
@ -117,7 +117,7 @@ impl TestAppContext {
&mut self,
update: impl FnOnce(&mut G, &mut AppContext) -> R,
) -> R {
let mut lock = self.app.borrow_mut("test_context.rs::update_global");
let mut lock = self.app.borrow_mut();
lock.update_global(update)
}

View file

@ -69,7 +69,7 @@ pub(crate) trait Platform: 'static {
fn set_display_link_output_callback(
&self,
display_id: DisplayId,
callback: Box<dyn FnMut(&VideoTimestamp, &VideoTimestamp)>,
callback: Box<dyn FnMut(&VideoTimestamp, &VideoTimestamp) + Send>,
);
fn start_display_link(&self, display_id: DisplayId);
fn stop_display_link(&self, display_id: DisplayId);

View file

@ -26,13 +26,13 @@ impl MacDisplayLinker {
}
}
type OutputCallback = Mutex<Box<dyn FnMut(&VideoTimestamp, &VideoTimestamp)>>;
type OutputCallback = Mutex<Box<dyn FnMut(&VideoTimestamp, &VideoTimestamp) + Send>>;
impl MacDisplayLinker {
pub fn set_output_callback(
&mut self,
display_id: DisplayId,
output_callback: Box<dyn FnMut(&VideoTimestamp, &VideoTimestamp)>,
output_callback: Box<dyn FnMut(&VideoTimestamp, &VideoTimestamp) + Send>,
) {
if let Some(mut system_link) = unsafe { sys::DisplayLink::on_display(display_id.0) } {
let callback = Arc::new(Mutex::new(output_callback));

View file

@ -494,7 +494,7 @@ impl Platform for MacPlatform {
fn set_display_link_output_callback(
&self,
display_id: DisplayId,
callback: Box<dyn FnMut(&VideoTimestamp, &VideoTimestamp)>,
callback: Box<dyn FnMut(&VideoTimestamp, &VideoTimestamp) + Send>,
) {
self.0
.lock()

View file

@ -81,7 +81,7 @@ impl Platform for TestPlatform {
fn set_display_link_output_callback(
&self,
_display_id: DisplayId,
_callback: Box<dyn FnMut(&crate::VideoTimestamp, &crate::VideoTimestamp)>,
_callback: Box<dyn FnMut(&crate::VideoTimestamp, &crate::VideoTimestamp) + Send>,
) {
unimplemented!()
}

View file

@ -62,6 +62,9 @@ mod stories {
"https://avatars.githubusercontent.com/u/326587?v=4",
))
// .child(Avatar::new(
// "https://avatars.githubusercontent.com/u/326587?v=4",
// ))
// .child(Avatar::new(
// "https://avatars.githubusercontent.com/u/482957?v=4",
// ))
// .child(Avatar::new(