From 10f367a31375e127f61ed5c45b69d1e120af7e16 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 29 Jul 2024 23:00:16 +0200 Subject: Avoid exiting when a window is being opened Fixes #2532 --- winit/src/program.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'winit/src/program.rs') 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( } = 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( )); let _ = on_open.send(id); + is_window_opening = false; } Event::EventLoopAwakened(event) => { match event { @@ -742,6 +743,7 @@ async fn run_instance( &mut user_interfaces, &mut window_manager, &mut ui_caches, + &mut is_window_opening, ); actions += 1; } @@ -926,16 +928,14 @@ async fn run_instance( 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( >, window_manager: &mut WindowManager, ui_caches: &mut FxHashMap, + is_window_opening: &mut bool, ) where P: Program, C: Compositor + 'static, @@ -1187,6 +1188,8 @@ fn run_action( on_open: channel, }) .expect("Send control action"); + + *is_window_opening = true; } window::Action::Close(id) => { let _ = window_manager.remove(id); -- cgit