Skip to content

Commit 15a6b5e

Browse files
authored
Handle the case where there is no resume time. (#23885)
# Objective - Fix the case where the UpdateMode::reactive is set to Duration::MAX. ## Solution - When `StartCause::WaitCancelled::requested_resume` is `None`, always report this case as not having elapsed the wait time. ## Testing - Ran the desktop_request_redraw with `UpdateMode::reactive(Duration::MAX)` and now it updates only when a redraw happens or a window even happens!
1 parent ec2b9db commit 15a6b5e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

crates/bevy_winit/src/state.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,13 @@ impl ApplicationHandler<WinitUserEvent> for WinitAppRunnerState {
163163

164164
self.wait_elapsed = match cause {
165165
StartCause::WaitCancelled {
166-
requested_resume: Some(resume),
167-
..
166+
requested_resume, ..
168167
} => {
169168
// If the resume time is not after now, it means that at least the wait timeout
170-
// has elapsed.
171-
resume <= Instant::now()
169+
// has elapsed. Alternatively, if the resume time is unset, the wait never elapses.
170+
requested_resume
171+
.map(|resume| resume <= Instant::now())
172+
.unwrap_or_default()
172173
}
173174
_ => true,
174175
};

0 commit comments

Comments
 (0)