-
Notifications
You must be signed in to change notification settings - Fork 947
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
Drop application handler on run loop exit #4149
base: master
Are you sure you want to change the base?
Conversation
814757d
to
f9e99a1
Compare
I'm in favor of doing so, however there's a case for What do you think about keeping the Also, there're cases where the user doesn't really want to drop their entire state in case of e.g. To sum up, for |
For let mut app = App::default();
event_loop.run_app_on_demand(&mut app)?;
// exited()
event_loop.run_app_on_demand(&mut app)?;
// exited()
loop {
let status = event_loop.pump_app_events(Some(Duration::ZERO), &mut app);
if let PumpStatus::Exit(exit_code) = status {
// exited()
break ExitCode::from(exit_code as u8);
}
sleep(Duration::from_millis(16));
} |
I've also thought about this, however For |
Hmm, is that actually required by any backends? We don't drop the window in the If so, this could still be handled by the user with: struct PartialApp<'app> {
app: &'app App,
windows: Vec<Box<dyn Window>>,
}
let mut app = App::default();
let partial_app = PartialApp { persistent: &mut app, windows: vec![] };
event_loop.run_app_on_demand(partial_app)?;
let partial_app = PartialApp { persistent: &mut app, windows: vec![] };
event_loop.run_app_on_demand(partial_app)?; Of course, that's more verbose, but IMO also clearer what happens state-wise.
Indeed, window cleanup should generally be done in |
Responding to #4146 (comment) (posted in the wrong place).
I suspect that's just a bug of the current implementation ( |
Looked in to #4135 now, and we can indeed do the cleanup correctly there, by force-closing windows before exiting (which will trigger |
Instead of the explicit `ApplicationHandler::exiting` event.
f9e99a1
to
88ef336
Compare
Notes from meeting: It may have issues with the display needing to be shut down between |
Part of #2903, split out from #3895. This is the motivation for doing #3721.
Calling the
Drop
impl of the user'sApplicationHandler
is important on macOS, iOS and Web, since they don't necessarily return fromEventLoop::run_app
. This PR fixes that.And now that we reliably call
Drop
, theApplicationHandler::exited
event/callback is unnecessary; usingDrop
composes much better (open files etc. stored in the app state will be automatically flushed), and prevents weirdness like attempting to create a new window while exiting. So this PR also removes that method.changelog
module if knowledge of this change could be valuable to users