diff options
author | 2024-07-29 23:00:16 +0200 | |
---|---|---|
committer | 2024-07-30 00:51:46 +0200 | |
commit | 10f367a31375e127f61ed5c45b69d1e120af7e16 (patch) | |
tree | f596da6a9607b076d043951b1d159fce02a8427d /winit | |
parent | ddd48ca14f14210d92a17632a8fce467786c7494 (diff) | |
download | iced-10f367a31375e127f61ed5c45b69d1e120af7e16.tar.gz iced-10f367a31375e127f61ed5c45b69d1e120af7e16.tar.bz2 iced-10f367a31375e127f61ed5c45b69d1e120af7e16.zip |
Avoid exiting when a window is being opened
Fixes #2532
Diffstat (limited to 'winit')
-rw-r--r-- | winit/src/program.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/winit/src/program.rs b/winit/src/program.rs index 872c8a98..286fff77 100644 --- a/winit/src/program.rs +++ b/winit/src/program.rs @@ -650,7 +650,7 @@ async fn run_instance<P, C>( } = boot.try_recv().ok().flatten().expect("Receive boot"); 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 messages = Vec::new(); @@ -706,6 +706,7 @@ async fn run_instance<P, C>( )); let _ = on_open.send(id); + is_window_opening = false; } Event::EventLoopAwakened(event) => { match event { @@ -742,6 +743,7 @@ async fn run_instance<P, C>( &mut user_interfaces, &mut window_manager, &mut ui_caches, + &mut is_window_opening, ); actions += 1; } @@ -926,16 +928,14 @@ async fn run_instance<P, C>( window_event, winit::event::WindowEvent::Destroyed ) + && !is_window_opening + && window_manager.is_empty() { - if boot_window_closed && window_manager.is_empty() { - control_sender - .start_send(Control::Exit) - .expect("Send control action"); + control_sender + .start_send(Control::Exit) + .expect("Send control action"); - continue; - } - - boot_window_closed = true; + continue; } let Some((id, window)) = @@ -1153,6 +1153,7 @@ fn run_action<P, C>( >, window_manager: &mut WindowManager<P, C>, ui_caches: &mut FxHashMap<window::Id, user_interface::Cache>, + is_window_opening: &mut bool, ) where P: Program, C: Compositor<Renderer = P::Renderer> + 'static, @@ -1187,6 +1188,8 @@ fn run_action<P, C>( on_open: channel, }) .expect("Send control action"); + + *is_window_opening = true; } window::Action::Close(id) => { let _ = window_manager.remove(id); |