Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application::run returns on native platforms #1112

Merged
merged 3 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions glutin/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ where
use futures::task;
use futures::Future;
use glutin::event_loop::EventLoop;
use glutin::platform::run_return::EventLoopExtRunReturn;
use glutin::ContextBuilder;

let mut debug = Debug::new();
debug.startup_started();

let event_loop = EventLoop::with_user_event();
let mut event_loop = EventLoop::with_user_event();
let mut proxy = event_loop.create_proxy();

let mut runtime = {
Expand Down Expand Up @@ -115,7 +116,7 @@ where

let mut context = task::Context::from_waker(task::noop_waker_ref());

event_loop.run(move |event, _, control_flow| {
event_loop.run_return(move |event, _, control_flow| {
use glutin::event_loop::ControlFlow;

if let ControlFlow::Exit = control_flow {
Expand Down Expand Up @@ -148,6 +149,8 @@ where
};
}
});

Ok(())
}

async fn run_instance<A, E, C>(
Expand Down
5 changes: 3 additions & 2 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@ pub trait Application: Sized {
/// Runs the [`Application`].
///
/// On native platforms, this method will take control of the current thread
/// and __will NOT return__ unless there is an [`Error`] during startup.
/// until the [`Application`] exits.
///
/// It should probably be that last thing you call in your `main` function.
/// On the web platform, this method __will NOT return__ unless there is an
/// [`Error`] during startup.
///
/// [`Error`]: crate::Error
fn run(settings: Settings<Self::Flags>) -> crate::Result
Expand Down
9 changes: 6 additions & 3 deletions winit/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ where
use futures::task;
use futures::Future;
use winit::event_loop::EventLoop;
use winit::platform::run_return::EventLoopExtRunReturn;

let mut debug = Debug::new();
debug.startup_started();

let event_loop = EventLoop::with_user_event();
let mut event_loop = EventLoop::with_user_event();
let mut proxy = event_loop.create_proxy();

let mut runtime = {
Expand Down Expand Up @@ -178,7 +179,7 @@ where

let mut context = task::Context::from_waker(task::noop_waker_ref());

event_loop.run(move |event, _, control_flow| {
event_loop.run_return(move |event, _, control_flow| {
use winit::event_loop::ControlFlow;

if let ControlFlow::Exit = control_flow {
Expand Down Expand Up @@ -211,6 +212,8 @@ where
};
}
});

Ok(())
}

async fn run_instance<A, E, C>(
Expand Down Expand Up @@ -401,7 +404,7 @@ async fn run_instance<A, E, C>(
Err(error) => match error {
// This is an unrecoverable error.
window::SurfaceError::OutOfMemory => {
panic!("{}", error);
panic!("{:?}", error);
}
_ => {
debug.render_finished();
Expand Down