mirror of
https://github.com/edera-dev/sprout.git
synced 2025-12-19 21:20:17 +00:00
fix(menu): handle event freeing if wait for event fails
This commit is contained in:
10
src/menu.rs
10
src/menu.rs
@@ -56,9 +56,12 @@ fn read(input: &mut Input, timeout: &Duration) -> Result<MenuOperation> {
|
||||
uefi::boot::set_timer(&timer_event, trigger).context("unable to set timeout timer")?;
|
||||
|
||||
let mut events = vec![timer_event, key_event];
|
||||
let event = uefi::boot::wait_for_event(&mut events)
|
||||
|
||||
// Wait for either the timer event or the key event to trigger.
|
||||
// Store the result so that we can free the timer event.
|
||||
let event_result = uefi::boot::wait_for_event(&mut events)
|
||||
.discard_errdata()
|
||||
.context("unable to wait for event")?;
|
||||
.context("unable to wait for event");
|
||||
|
||||
// Close the timer event that we acquired.
|
||||
// We don't need to close the key event because it is owned globally.
|
||||
@@ -66,6 +69,9 @@ fn read(input: &mut Input, timeout: &Duration) -> Result<MenuOperation> {
|
||||
uefi::boot::close_event(timer_event).context("unable to close timer event")?;
|
||||
}
|
||||
|
||||
// Acquire the event that triggered.
|
||||
let event = event_result?;
|
||||
|
||||
// The first event is the timer event.
|
||||
// If it has triggered, the user did not select a numbered entry.
|
||||
if event == 0 {
|
||||
|
||||
Reference in New Issue
Block a user