Avoid panic by only restoring workspace if UI has launched (#18386)
This should fix the `unregistered setting type workspace::workspace_settings::WorkspaceSettings` panic that came from inside `restorable_workspace_locations`. We tracked it down to a possible scenario (we can't recreate it though) in which `app.on_reopen` is called before the app has finished launching. In any case, this check makes sense, because we only want to restore a workspace in case the whole app has launched with a UI. Release Notes: - N/A Co-authored-by: Bennet <bennet@zed.dev>
This commit is contained in:
parent
b9b689d322
commit
140d70289e
1 changed files with 15 additions and 8 deletions
|
@ -425,15 +425,22 @@ fn main() {
|
|||
app.on_reopen(move |cx| {
|
||||
if let Some(app_state) = AppState::try_global(cx).and_then(|app_state| app_state.upgrade())
|
||||
{
|
||||
cx.spawn({
|
||||
let app_state = app_state.clone();
|
||||
|mut cx| async move {
|
||||
if let Err(e) = restore_or_create_workspace(app_state, &mut cx).await {
|
||||
fail_to_open_window_async(e, &mut cx)
|
||||
let ui_has_launched = cx
|
||||
.try_global::<AppMode>()
|
||||
.map(|mode| matches!(mode, AppMode::Ui))
|
||||
.unwrap_or(false);
|
||||
|
||||
if ui_has_launched {
|
||||
cx.spawn({
|
||||
let app_state = app_state.clone();
|
||||
|mut cx| async move {
|
||||
if let Err(e) = restore_or_create_workspace(app_state, &mut cx).await {
|
||||
fail_to_open_window_async(e, &mut cx)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue