Skip to content

Commit

Permalink
lsp: Fix error reporting when opening the live-preview fails
Browse files Browse the repository at this point in the history
Fixes: #7255
  • Loading branch information
hunger committed Jan 6, 2025
1 parent 1202308 commit e1e8f04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions tools/lsp/preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ pub fn load_preview(preview_component: PreviewComponent, behavior: LoadBehavior)
cache.loading_state = PreviewFutureState::PreLoading;
};

run_in_ui_thread(move || async move {
if let Err(e) = run_in_ui_thread(move || async move {
PREVIEW_STATE.with(|preview_state| {
preview_state
.borrow_mut()
Expand All @@ -1261,15 +1261,16 @@ pub fn load_preview(preview_component: PreviewComponent, behavior: LoadBehavior)
slint::TimerMode::SingleShot,
core::time::Duration::from_millis(50),
|| {
slint::spawn_local(reload_timer_function()).unwrap();
let _ = slint::spawn_local(reload_timer_function());
},
);
timer
})
.restart();
});
})
.unwrap();
}) {
send_platform_error_notification(&e);
}
}

async fn parse_source(
Expand Down
4 changes: 2 additions & 2 deletions tools/lsp/preview/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ pub fn run_in_ui_thread<F: Future<Output = ()> + 'static>(
return Err(err.clone());
}
}

i_slint_core::api::invoke_from_event_loop(move || {
slint::spawn_local(create_future()).unwrap();
})
.unwrap();
Ok(())
.map_err(|e| e.to_string())
}

/// This is the main entry for the Slint event loop. It runs on the main thread,
Expand Down

0 comments on commit e1e8f04

Please sign in to comment.