Propagate error from EventLoop creation
Inner panics could make it hard to trouble shoot the issues and for some users it's not desirable. The inner panics were left only when they are used to `assert!` during development. This reverts commit 9f91bc413fe20618bd7090829832bb074aab15c3 which reverted the original patch which was merged without a proper review. Fixes: #500.
This commit is contained in:
parent
778d70c001
commit
f9758528f6
59 changed files with 353 additions and 297 deletions
|
|
@ -29,7 +29,7 @@ use crate::{
|
|||
self, CursorGrabMode, ImePurpose, ResizeDirection, Theme, WindowButtons, WindowLevel,
|
||||
},
|
||||
};
|
||||
use crate::{error::RunLoopError, platform_impl::Fullscreen};
|
||||
use crate::{error::EventLoopError, platform_impl::Fullscreen};
|
||||
|
||||
mod keycodes;
|
||||
|
||||
|
|
@ -186,13 +186,15 @@ fn sticky_exit_callback<T, F>(
|
|||
}
|
||||
|
||||
impl<T: 'static> EventLoop<T> {
|
||||
pub(crate) fn new(attributes: &PlatformSpecificEventLoopAttributes) -> Self {
|
||||
pub(crate) fn new(
|
||||
attributes: &PlatformSpecificEventLoopAttributes,
|
||||
) -> Result<Self, EventLoopError> {
|
||||
let (user_events_sender, user_events_receiver) = mpsc::channel();
|
||||
|
||||
let android_app = attributes.android_app.as_ref().expect("An `AndroidApp` as passed to android_main() is required to create an `EventLoop` on Android");
|
||||
let redraw_flag = SharedFlag::new();
|
||||
|
||||
Self {
|
||||
Ok(Self {
|
||||
android_app: android_app.clone(),
|
||||
window_target: event_loop::EventLoopWindowTarget {
|
||||
p: EventLoopWindowTarget {
|
||||
|
|
@ -215,7 +217,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
cause: StartCause::Init,
|
||||
ignore_volume_keys: attributes.ignore_volume_keys,
|
||||
combining_accent: None,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn single_iteration<F>(&mut self, main_event: Option<MainEvent<'_>>, callback: &mut F)
|
||||
|
|
@ -533,19 +535,19 @@ impl<T: 'static> EventLoop<T> {
|
|||
input_status
|
||||
}
|
||||
|
||||
pub fn run<F>(mut self, event_handler: F) -> Result<(), RunLoopError>
|
||||
pub fn run<F>(mut self, event_handler: F) -> Result<(), EventLoopError>
|
||||
where
|
||||
F: FnMut(event::Event<T>, &event_loop::EventLoopWindowTarget<T>, &mut ControlFlow),
|
||||
{
|
||||
self.run_ondemand(event_handler)
|
||||
}
|
||||
|
||||
pub fn run_ondemand<F>(&mut self, mut event_handler: F) -> Result<(), RunLoopError>
|
||||
pub fn run_ondemand<F>(&mut self, mut event_handler: F) -> Result<(), EventLoopError>
|
||||
where
|
||||
F: FnMut(event::Event<T>, &event_loop::EventLoopWindowTarget<T>, &mut ControlFlow),
|
||||
{
|
||||
if self.loop_running {
|
||||
return Err(RunLoopError::AlreadyRunning);
|
||||
return Err(EventLoopError::AlreadyRunning);
|
||||
}
|
||||
|
||||
loop {
|
||||
|
|
@ -554,7 +556,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
break Ok(());
|
||||
}
|
||||
PumpStatus::Exit(code) => {
|
||||
break Err(RunLoopError::ExitFailure(code));
|
||||
break Err(EventLoopError::ExitFailure(code));
|
||||
}
|
||||
_ => {
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue