Change run_app(app: &mut A) to run_app(app: A) (#3721)
This allows the user more control over how they pass their application state to Winit, and will hopefully allow `Drop` implementations on the application handler to work in the future on all platforms.
This commit is contained in:
parent
d5fd8682eb
commit
bf97def398
17 changed files with 53 additions and 59 deletions
|
|
@ -243,7 +243,7 @@ impl EventLoop {
|
|||
&self.window_target
|
||||
}
|
||||
|
||||
pub fn run_app<A: ApplicationHandler>(mut self, app: &mut A) -> Result<(), EventLoopError> {
|
||||
pub fn run_app<A: ApplicationHandler>(mut self, app: A) -> Result<(), EventLoopError> {
|
||||
self.run_app_on_demand(app)
|
||||
}
|
||||
|
||||
|
|
@ -253,9 +253,9 @@ impl EventLoop {
|
|||
// redundant wake ups.
|
||||
pub fn run_app_on_demand<A: ApplicationHandler>(
|
||||
&mut self,
|
||||
app: &mut A,
|
||||
mut app: A,
|
||||
) -> Result<(), EventLoopError> {
|
||||
self.delegate.set_event_handler(app, || {
|
||||
self.delegate.set_event_handler(&mut app, || {
|
||||
autoreleasepool(|_| {
|
||||
// clear / normalize pump_events state
|
||||
self.delegate.set_wait_timeout(None);
|
||||
|
|
@ -291,9 +291,9 @@ impl EventLoop {
|
|||
pub fn pump_app_events<A: ApplicationHandler>(
|
||||
&mut self,
|
||||
timeout: Option<Duration>,
|
||||
app: &mut A,
|
||||
mut app: A,
|
||||
) -> PumpStatus {
|
||||
self.delegate.set_event_handler(app, || {
|
||||
self.delegate.set_event_handler(&mut app, || {
|
||||
autoreleasepool(|_| {
|
||||
// As a special case, if the application hasn't been launched yet then we at least
|
||||
// run the loop until it has fully launched.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue