diff options
author | 2021-03-31 10:20:22 +0200 | |
---|---|---|
committer | 2021-03-31 10:20:22 +0200 | |
commit | b9ec44446ed4d99b9b17aceafdcb353dd1595877 (patch) | |
tree | 86b3e4d9a7257a6d5b0d82988111f2a3a5ca7117 /glutin | |
parent | bbb4e4678f14b4b187f9537a32063440e727e919 (diff) | |
parent | 8f952452ce3d61203856bcebae7016372556be31 (diff) | |
download | iced-b9ec44446ed4d99b9b17aceafdcb353dd1595877.tar.gz iced-b9ec44446ed4d99b9b17aceafdcb353dd1595877.tar.bz2 iced-b9ec44446ed4d99b9b17aceafdcb353dd1595877.zip |
Merge pull request #804 from hecrj/feature/graceful-exit
Graceful exiting for `Application`
Diffstat (limited to 'glutin')
-rw-r--r-- | glutin/src/application.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/glutin/src/application.rs b/glutin/src/application.rs index 163bc9f9..79fcf745 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -92,10 +92,11 @@ where application, compositor, renderer, - context, runtime, debug, receiver, + context, + settings.exit_on_close_request, )); let mut context = task::Context::from_waker(task::noop_waker_ref()); @@ -139,10 +140,11 @@ async fn run_instance<A, E, C>( mut application: A, mut compositor: C, mut renderer: A::Renderer, - context: glutin::ContextWrapper<glutin::PossiblyCurrent, Window>, mut runtime: Runtime<E, Proxy<A::Message>, A::Message>, mut debug: Debug, mut receiver: mpsc::UnboundedReceiver<glutin::event::Event<'_, A::Message>>, + context: glutin::ContextWrapper<glutin::PossiblyCurrent, Window>, + exit_on_close_request: bool, ) where A: Application + 'static, E: Executor + 'static, @@ -212,6 +214,8 @@ async fn run_instance<A, E, C>( // Update window state.synchronize(&application, context.window()); + let should_exit = application.should_exit(); + user_interface = ManuallyDrop::new(application::build_user_interface( &mut application, @@ -220,6 +224,10 @@ async fn run_instance<A, E, C>( state.logical_size(), &mut debug, )); + + if should_exit { + break; + } } debug.draw_started(); @@ -290,6 +298,7 @@ async fn run_instance<A, E, C>( .. } => { if application::requests_exit(&window_event, state.modifiers()) + && exit_on_close_request { break; } |