Fix macOS race condition when closing window
This commit is contained in:
parent
884c66ca15
commit
a5b1a1df54
1 changed files with 11 additions and 9 deletions
|
|
@ -320,7 +320,6 @@ where
|
|||
.send(Boot {
|
||||
compositor,
|
||||
clipboard,
|
||||
window: window.id(),
|
||||
})
|
||||
.ok()
|
||||
.expect("Send boot event");
|
||||
|
|
@ -601,9 +600,9 @@ where
|
|||
struct Boot<C> {
|
||||
compositor: C,
|
||||
clipboard: Clipboard,
|
||||
window: winit::window::WindowId,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum Event<Message: 'static> {
|
||||
WindowCreated {
|
||||
id: window::Id,
|
||||
|
|
@ -615,6 +614,7 @@ enum Event<Message: 'static> {
|
|||
EventLoopAwakened(winit::event::Event<Message>),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum Control {
|
||||
ChangeFlow(winit::event_loop::ControlFlow),
|
||||
Exit,
|
||||
|
|
@ -647,10 +647,10 @@ async fn run_instance<P, C>(
|
|||
let Boot {
|
||||
mut compositor,
|
||||
mut clipboard,
|
||||
window: boot_window,
|
||||
} = boot.try_recv().ok().flatten().expect("Receive boot");
|
||||
|
||||
let mut window_manager = WindowManager::new();
|
||||
let mut boot_window_closed = false;
|
||||
|
||||
let mut events = Vec::new();
|
||||
let mut messages = Vec::new();
|
||||
|
|
@ -926,9 +926,8 @@ async fn run_instance<P, C>(
|
|||
window_event,
|
||||
winit::event::WindowEvent::Destroyed
|
||||
)
|
||||
&& window_id != boot_window
|
||||
&& window_manager.is_empty()
|
||||
{
|
||||
if boot_window_closed && window_manager.is_empty() {
|
||||
control_sender
|
||||
.start_send(Control::Exit)
|
||||
.expect("Send control action");
|
||||
|
|
@ -936,6 +935,9 @@ async fn run_instance<P, C>(
|
|||
continue;
|
||||
}
|
||||
|
||||
boot_window_closed = true;
|
||||
}
|
||||
|
||||
let Some((id, window)) =
|
||||
window_manager.get_mut_alias(window_id)
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue