Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions crates/gpui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1462,29 +1462,33 @@ impl App {

cx.window_update_stack.push(window.handle.id);
let result = update(root_view, &mut window, cx);
cx.window_update_stack.pop();
fn trail(id: WindowId, window: Box<Window>, cx: &mut App) -> Option<()> {
cx.window_update_stack.pop();

if window.removed {
cx.window_handles.remove(&id);
cx.windows.remove(id);
if window.removed {
cx.window_handles.remove(&id);
cx.windows.remove(id);

cx.window_closed_observers.clone().retain(&(), |callback| {
callback(cx);
true
});
cx.window_closed_observers.clone().retain(&(), |callback| {
callback(cx);
true
});

let quit_on_empty = match cx.quit_mode {
QuitMode::Explicit => false,
QuitMode::LastWindowClosed => true,
QuitMode::Default => cfg!(not(target_os = "macos")),
};
let quit_on_empty = match cx.quit_mode {
QuitMode::Explicit => false,
QuitMode::LastWindowClosed => true,
QuitMode::Default => cfg!(not(target_os = "macos")),
};

if quit_on_empty && cx.windows.is_empty() {
cx.quit();
if quit_on_empty && cx.windows.is_empty() {
cx.quit();
}
} else {
cx.windows.get_mut(id)?.replace(window);
}
} else {
cx.windows.get_mut(id)?.replace(window);
Some(())
}
trail(id, window, cx)?;

Some(result)
})
Expand Down Expand Up @@ -1529,7 +1533,7 @@ impl App {
let mut cx = self.to_async();

self.foreground_executor
.spawn(async move { f(&mut cx).await })
.spawn(async move { f(&mut cx).await }.boxed_local())
}

/// Spawns the future returned by the given function on the main thread with
Expand All @@ -1547,7 +1551,7 @@ impl App {
let mut cx = self.to_async();

self.foreground_executor
.spawn_with_priority(priority, async move { f(&mut cx).await })
.spawn_with_priority(priority, async move { f(&mut cx).await }.boxed_local())
}

/// Schedules the given function to be run at the end of the current effect cycle, allowing entities
Expand Down
5 changes: 3 additions & 2 deletions crates/gpui/src/app/async_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
use anyhow::Context as _;
use derive_more::{Deref, DerefMut};
use futures::channel::oneshot;
use smol::future::FutureExt;
use std::{future::Future, rc::Weak};

use super::{Context, WeakEntity};
Expand Down Expand Up @@ -184,7 +185,7 @@ impl AsyncApp {
{
let mut cx = self.clone();
self.foreground_executor
.spawn(async move { f(&mut cx).await })
.spawn(async move { f(&mut cx).await }.boxed_local())
}

/// Determine whether global state of the specified type has been assigned.
Expand Down Expand Up @@ -322,7 +323,7 @@ impl AsyncWindowContext {
{
let mut cx = self.clone();
self.foreground_executor
.spawn(async move { f(&mut cx).await })
.spawn(async move { f(&mut cx).await }.boxed_local())
}

/// Present a platform dialog.
Expand Down
4 changes: 2 additions & 2 deletions crates/gpui/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl BackgroundExecutor {
where
R: Send + 'static,
{
self.spawn_with_priority(Priority::default(), future)
self.spawn_with_priority(Priority::default(), future.boxed())
}

/// Enqueues the given future to be run to completion on a background thread with the given priority.
Expand Down Expand Up @@ -409,7 +409,7 @@ impl ForegroundExecutor {
where
R: 'static,
{
Task::from_scheduler(self.inner.spawn(future))
Task::from_scheduler(self.inner.spawn(future.boxed_local()))
}

/// Enqueues the given Task to run on the main thread with the given priority.
Expand Down