mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 08:03:19 +00:00
fix(updates): don't hold the update lock while asking which window is focused (#4523)
The automatic update announcement held updates.ready while asking a window whether it is focused (a main-thread round trip); a window starting up ran app_update_window_ready on the main thread and waited for the same lock, freezing startup with no window. The focused and live windows are now read before taking the lock.
This commit is contained in:
@@ -139,11 +139,14 @@ fn announce_available(app: &AppHandle) {
|
||||
return;
|
||||
}
|
||||
let state = app.state::<AppState>();
|
||||
// Asking a window whether it is focused waits for the main thread, where
|
||||
// `app_update_window_ready` takes `ready`: never hold the lock across it.
|
||||
let focused = crate::windows::target_window(app);
|
||||
let live = crate::windows::project_window_labels(app);
|
||||
let owner = {
|
||||
let mut ready = state.updates.ready.lock();
|
||||
ready.retain(|label| app.get_webview_window(label).is_some());
|
||||
let focused = crate::windows::target_window(app);
|
||||
ready_owner(focused.as_ref().map(|window| window.label()), &crate::windows::project_window_labels(app), &ready)
|
||||
ready_owner(focused.as_ref().map(|window| window.label()), &live, &ready)
|
||||
};
|
||||
let Some(owner) = owner else { return };
|
||||
let update = {
|
||||
|
||||
Reference in New Issue
Block a user