Avoid exiting when a window is being opened

Fixes #2532
This commit is contained in:
Héctor Ramón Jiménez 2024-07-29 23:00:16 +02:00
parent ddd48ca14f
commit 10f367a313
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -650,7 +650,7 @@ async fn run_instance<P, C>(
} = boot.try_recv().ok().flatten().expect("Receive boot"); } = boot.try_recv().ok().flatten().expect("Receive boot");
let mut window_manager = WindowManager::new(); let mut window_manager = WindowManager::new();
let mut boot_window_closed = false; let mut is_window_opening = !is_daemon;
let mut events = Vec::new(); let mut events = Vec::new();
let mut messages = Vec::new(); let mut messages = Vec::new();
@ -706,6 +706,7 @@ async fn run_instance<P, C>(
)); ));
let _ = on_open.send(id); let _ = on_open.send(id);
is_window_opening = false;
} }
Event::EventLoopAwakened(event) => { Event::EventLoopAwakened(event) => {
match event { match event {
@ -742,6 +743,7 @@ async fn run_instance<P, C>(
&mut user_interfaces, &mut user_interfaces,
&mut window_manager, &mut window_manager,
&mut ui_caches, &mut ui_caches,
&mut is_window_opening,
); );
actions += 1; actions += 1;
} }
@ -926,16 +928,14 @@ async fn run_instance<P, C>(
window_event, window_event,
winit::event::WindowEvent::Destroyed winit::event::WindowEvent::Destroyed
) )
&& !is_window_opening
&& window_manager.is_empty()
{ {
if boot_window_closed && window_manager.is_empty() { control_sender
control_sender .start_send(Control::Exit)
.start_send(Control::Exit) .expect("Send control action");
.expect("Send control action");
continue; continue;
}
boot_window_closed = true;
} }
let Some((id, window)) = let Some((id, window)) =
@ -1153,6 +1153,7 @@ fn run_action<P, C>(
>, >,
window_manager: &mut WindowManager<P, C>, window_manager: &mut WindowManager<P, C>,
ui_caches: &mut FxHashMap<window::Id, user_interface::Cache>, ui_caches: &mut FxHashMap<window::Id, user_interface::Cache>,
is_window_opening: &mut bool,
) where ) where
P: Program, P: Program,
C: Compositor<Renderer = P::Renderer> + 'static, C: Compositor<Renderer = P::Renderer> + 'static,
@ -1187,6 +1188,8 @@ fn run_action<P, C>(
on_open: channel, on_open: channel,
}) })
.expect("Send control action"); .expect("Send control action");
*is_window_opening = true;
} }
window::Action::Close(id) => { window::Action::Close(id) => {
let _ = window_manager.remove(id); let _ = window_manager.remove(id);