diff --git a/crates/gpui3/src/app.rs b/crates/gpui3/src/app.rs index 7702856d6b4af1c7559add20dbb2c354e5f8c419..69f88b0cb4ae08c3af855bb582fa6292a07d31f3 100644 --- a/crates/gpui3/src/app.rs +++ b/crates/gpui3/src/app.rs @@ -47,9 +47,10 @@ impl App { where F: 'static + FnOnce(&mut AppContext), { + let this = self.clone(); let platform = self.0.lock().platform.clone(); platform.borrow_on_main_thread().run(Box::new(move || { - let cx = &mut *self.0.lock(); + let cx = &mut *this.0.lock(); on_finish_launching(cx); })); } diff --git a/crates/gpui3/src/gpui3.rs b/crates/gpui3/src/gpui3.rs index c364b68a7b7e714e78ca4c47aeff9b85e7c574a4..b62545cd83d8714f876ffe8f96290458fcc36e38 100644 --- a/crates/gpui3/src/gpui3.rs +++ b/crates/gpui3/src/gpui3.rs @@ -149,19 +149,12 @@ impl MainThreadOnly { where R: Send + 'static, { - let (tx, rx) = oneshot::channel(); - if self.dispatcher.is_main_thread() { - let _ = tx.send(f(&self.value)); - } else { - let this = self.clone(); - let _ = crate::spawn_on_main(self.dispatcher.clone(), async move { - // Required so we move `this` instead of this.value. Only `this` is `Send`. - let this = this; - let _ = tx.send(f(&this.value)); - }); - } - - async move { rx.await.unwrap() } + let this = self.clone(); + crate::spawn_on_main(self.dispatcher.clone(), async move { + // Required so we move `this` instead of this.value. Only `this` is `Send`. + let this = this; + f(&this.value) + }) } }