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,6 +425,12 @@ fn main() {
|
||||||
app.on_reopen(move |cx| {
|
app.on_reopen(move |cx| {
|
||||||
if let Some(app_state) = AppState::try_global(cx).and_then(|app_state| app_state.upgrade())
|
if let Some(app_state) = AppState::try_global(cx).and_then(|app_state| app_state.upgrade())
|
||||||
{
|
{
|
||||||
|
let ui_has_launched = cx
|
||||||
|
.try_global::<AppMode>()
|
||||||
|
.map(|mode| matches!(mode, AppMode::Ui))
|
||||||
|
.unwrap_or(false);
|
||||||
|
|
||||||
|
if ui_has_launched {
|
||||||
cx.spawn({
|
cx.spawn({
|
||||||
let app_state = app_state.clone();
|
let app_state = app_state.clone();
|
||||||
|mut cx| async move {
|
|mut cx| async move {
|
||||||
|
@ -435,6 +441,7 @@ fn main() {
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.run(move |cx| {
|
app.run(move |cx| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue