Merge pull request #1112 from AndiHofi/on_exit_callback
Application::run returns on native platforms
This commit is contained in:
commit
d9f970ffd5
3 changed files with 14 additions and 7 deletions
|
|
@ -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 = {
|
||||
|
|
@ -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 {
|
||||
|
|
@ -148,6 +149,8 @@ where
|
|||
};
|
||||
}
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn run_instance<A, E, C>(
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
@ -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 {
|
||||
|
|
@ -211,6 +212,8 @@ where
|
|||
};
|
||||
}
|
||||
});
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn run_instance<A, E, C>(
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue