Revert "Propagate error from EventLoop creation" (#3010)
This reverts commit ed26dd58fd.
The patched was merged with a review by accident.
This commit is contained in:
parent
ed26dd58fd
commit
793c535b01
57 changed files with 291 additions and 344 deletions
|
|
@ -24,7 +24,7 @@ use raw_window_handle::{AppKitDisplayHandle, RawDisplayHandle};
|
|||
|
||||
use super::appkit::{NSApp, NSApplicationActivationPolicy, NSEvent, NSWindow};
|
||||
use crate::{
|
||||
error::EventLoopError,
|
||||
error::RunLoopError,
|
||||
event::Event,
|
||||
event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootWindowTarget},
|
||||
platform::{macos::ActivationPolicy, pump_events::PumpStatus},
|
||||
|
|
@ -148,9 +148,7 @@ impl Default for PlatformSpecificEventLoopAttributes {
|
|||
}
|
||||
|
||||
impl<T> EventLoop<T> {
|
||||
pub(crate) fn new(
|
||||
attributes: &PlatformSpecificEventLoopAttributes,
|
||||
) -> Result<Self, EventLoopError> {
|
||||
pub(crate) fn new(attributes: &PlatformSpecificEventLoopAttributes) -> Self {
|
||||
if !is_main_thread() {
|
||||
panic!("On macOS, `EventLoop` must be created on the main thread!");
|
||||
}
|
||||
|
|
@ -180,7 +178,7 @@ impl<T> EventLoop<T> {
|
|||
|
||||
let panic_info: Rc<PanicInfo> = Default::default();
|
||||
setup_control_flow_observers(Rc::downgrade(&panic_info));
|
||||
Ok(EventLoop {
|
||||
EventLoop {
|
||||
_delegate: delegate,
|
||||
window_target: Rc::new(RootWindowTarget {
|
||||
p: Default::default(),
|
||||
|
|
@ -188,14 +186,14 @@ impl<T> EventLoop<T> {
|
|||
}),
|
||||
panic_info,
|
||||
_callback: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn window_target(&self) -> &RootWindowTarget<T> {
|
||||
&self.window_target
|
||||
}
|
||||
|
||||
pub fn run<F>(mut self, callback: F) -> Result<(), EventLoopError>
|
||||
pub fn run<F>(mut self, callback: F) -> Result<(), RunLoopError>
|
||||
where
|
||||
F: FnMut(Event<T>, &RootWindowTarget<T>, &mut ControlFlow),
|
||||
{
|
||||
|
|
@ -206,12 +204,12 @@ impl<T> EventLoop<T> {
|
|||
// `pump_events` elegantly (we just ask to run the loop for a "short" amount of
|
||||
// time and so a layered implementation would end up using a lot of CPU due to
|
||||
// redundant wake ups.
|
||||
pub fn run_ondemand<F>(&mut self, callback: F) -> Result<(), EventLoopError>
|
||||
pub fn run_ondemand<F>(&mut self, callback: F) -> Result<(), RunLoopError>
|
||||
where
|
||||
F: FnMut(Event<T>, &RootWindowTarget<T>, &mut ControlFlow),
|
||||
{
|
||||
if AppState::is_running() {
|
||||
return Err(EventLoopError::AlreadyRunning);
|
||||
return Err(RunLoopError::AlreadyRunning);
|
||||
}
|
||||
|
||||
// # Safety
|
||||
|
|
@ -289,7 +287,7 @@ impl<T> EventLoop<T> {
|
|||
if exit_code == 0 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(EventLoopError::ExitFailure(exit_code))
|
||||
Err(RunLoopError::ExitFailure(exit_code))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue