Skip to content

Commit

Permalink
Fix crash when application boots from a URL event in macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Aug 14, 2024
1 parent 515772c commit 7c2abc9
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions winit/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ async fn run_instance<P, C>(
mut runtime: Runtime<P::Executor, Proxy<P::Message>, Action<P::Message>>,
mut proxy: Proxy<P::Message>,
mut debug: Debug,
mut boot: oneshot::Receiver<Boot<C>>,
boot: oneshot::Receiver<Boot<C>>,
mut event_receiver: mpsc::UnboundedReceiver<Event<Action<P::Message>>>,
mut control_sender: mpsc::UnboundedSender<Control>,
is_daemon: bool,
Expand All @@ -665,7 +665,7 @@ async fn run_instance<P, C>(
let Boot {
mut compositor,
mut clipboard,
} = boot.try_recv().ok().flatten().expect("Receive boot");
} = boot.await.expect("Receive boot");

let mut window_manager = WindowManager::new();
let mut is_window_opening = !is_daemon;
Expand All @@ -679,7 +679,18 @@ async fn run_instance<P, C>(

debug.startup_finished();

while let Some(event) = event_receiver.next().await {
loop {
// Empty the queue if possible
let event = if let Ok(event) = event_receiver.try_next() {
event
} else {
event_receiver.next().await
};

let Some(event) = event else {
break;
};

match event {
Event::WindowCreated {
id,
Expand Down

0 comments on commit 7c2abc9

Please sign in to comment.