Rename LoopDestroyed to LoopExiting
Considering the possibility of re-running an event loop via run_ondemand then it's more correct to say that the loop is about to exit without assuming it's going to be destroyed.
This commit is contained in:
parent
755c533b08
commit
935146d299
15 changed files with 28 additions and 30 deletions
|
|
@ -585,7 +585,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
|
||||
let mut dummy = self.control_flow;
|
||||
sticky_exit_callback(
|
||||
event::Event::LoopDestroyed,
|
||||
event::Event::LoopExiting,
|
||||
self.window_target(),
|
||||
&mut dummy,
|
||||
&mut callback,
|
||||
|
|
|
|||
|
|
@ -444,10 +444,7 @@ impl AppState {
|
|||
fn terminated_transition(&mut self) -> Box<dyn EventHandler> {
|
||||
match self.replace_state(AppStateImpl::Terminated) {
|
||||
AppStateImpl::ProcessingEvents { event_handler, .. } => event_handler,
|
||||
s => bug!(
|
||||
"`LoopDestroyed` happened while not processing events {:?}",
|
||||
s
|
||||
),
|
||||
s => bug!("`LoopExiting` happened while not processing events {:?}", s),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -785,7 +782,7 @@ pub unsafe fn terminated() {
|
|||
let mut control_flow = this.control_flow;
|
||||
drop(this);
|
||||
|
||||
event_handler.handle_nonuser_event(Event::LoopDestroyed, &mut control_flow)
|
||||
event_handler.handle_nonuser_event(Event::LoopExiting, &mut control_flow)
|
||||
}
|
||||
|
||||
fn handle_event_proxy(
|
||||
|
|
|
|||
|
|
@ -48,12 +48,12 @@
|
|||
//!
|
||||
//! - applicationDidBecomeActive is Resumed
|
||||
//! - applicationWillResignActive is Suspended
|
||||
//! - applicationWillTerminate is LoopDestroyed
|
||||
//! - applicationWillTerminate is LoopExiting
|
||||
//!
|
||||
//! Keep in mind that after LoopDestroyed event is received every attempt to draw with
|
||||
//! Keep in mind that after LoopExiting event is received every attempt to draw with
|
||||
//! opengl will result in segfault.
|
||||
//!
|
||||
//! Also note that app may not receive the LoopDestroyed event if suspended; it might be SIGKILL'ed.
|
||||
//! Also note that app may not receive the LoopExiting event if suspended; it might be SIGKILL'ed.
|
||||
|
||||
#![cfg(ios_platform)]
|
||||
#![allow(clippy::let_unit_value)]
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
|
||||
let mut dummy = self.control_flow;
|
||||
sticky_exit_callback(
|
||||
Event::LoopDestroyed,
|
||||
Event::LoopExiting,
|
||||
self.window_target(),
|
||||
&mut dummy,
|
||||
&mut callback,
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
|
||||
let mut dummy = self.control_flow;
|
||||
sticky_exit_callback(
|
||||
Event::LoopDestroyed,
|
||||
Event::LoopExiting,
|
||||
self.window_target(),
|
||||
&mut dummy,
|
||||
&mut callback,
|
||||
|
|
|
|||
|
|
@ -436,7 +436,7 @@ impl AppState {
|
|||
|
||||
pub fn exit() -> i32 {
|
||||
HANDLER.set_in_callback(true);
|
||||
HANDLER.handle_nonuser_event(EventWrapper::StaticEvent(Event::LoopDestroyed));
|
||||
HANDLER.handle_nonuser_event(EventWrapper::StaticEvent(Event::LoopExiting));
|
||||
HANDLER.set_in_callback(false);
|
||||
HANDLER.exit();
|
||||
Self::clear_callback();
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ extern "C" fn control_flow_begin_handler(
|
|||
}
|
||||
|
||||
// end is queued with the lowest priority to ensure it is processed after other observers
|
||||
// without that, LoopDestroyed would get sent after MainEventsCleared
|
||||
// without that, LoopExiting would get sent after MainEventsCleared
|
||||
extern "C" fn control_flow_end_handler(
|
||||
_: CFRunLoopObserverRef,
|
||||
activity: CFRunLoopActivity,
|
||||
|
|
|
|||
|
|
@ -684,7 +684,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
};
|
||||
|
||||
event_handler(
|
||||
event::Event::LoopDestroyed,
|
||||
event::Event::LoopExiting,
|
||||
&self.window_target,
|
||||
&mut control_flow,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -585,7 +585,7 @@ impl<T: 'static> Shared<T> {
|
|||
let mut control = self.current_control_flow();
|
||||
// We don't call `handle_loop_destroyed` here because we don't need to
|
||||
// perform cleanup when the web browser is going to destroy the page.
|
||||
self.handle_event(Event::LoopDestroyed, &mut control);
|
||||
self.handle_event(Event::LoopExiting, &mut control);
|
||||
}
|
||||
|
||||
// handle_event takes in events and either queues them or applies a callback
|
||||
|
|
@ -665,7 +665,7 @@ impl<T: 'static> Shared<T> {
|
|||
}
|
||||
|
||||
fn handle_loop_destroyed(&self, control: &mut ControlFlow) {
|
||||
self.handle_event(Event::LoopDestroyed, control);
|
||||
self.handle_event(Event::LoopExiting, control);
|
||||
let all_canvases = std::mem::take(&mut *self.0.all_canvases.borrow_mut());
|
||||
*self.0.page_transition_event_handle.borrow_mut() = None;
|
||||
*self.0.on_mouse_move.borrow_mut() = None;
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
};
|
||||
|
||||
// We wait until we've checked for an exit status before clearing the
|
||||
// application callback, in case we need to dispatch a LoopDestroyed event
|
||||
// application callback, in case we need to dispatch a LoopExiting event
|
||||
//
|
||||
// # Safety
|
||||
// This pairs up with our call to `runner.set_event_handler` and ensures
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ impl<T> EventLoopRunner<T> {
|
|||
}
|
||||
|
||||
/// Dispatch control flow events (`NewEvents`, `MainEventsCleared`, `RedrawEventsCleared`, and
|
||||
/// `LoopDestroyed`) as necessary to bring the internal `RunnerState` to the new runner state.
|
||||
/// `LoopExiting`) as necessary to bring the internal `RunnerState` to the new runner state.
|
||||
///
|
||||
/// The state transitions are defined as follows:
|
||||
///
|
||||
|
|
@ -298,7 +298,7 @@ impl<T> EventLoopRunner<T> {
|
|||
self.call_new_events(true);
|
||||
self.call_event_handler(Event::MainEventsCleared);
|
||||
self.call_redraw_events_cleared();
|
||||
self.call_event_handler(Event::LoopDestroyed);
|
||||
self.call_event_handler(Event::LoopExiting);
|
||||
}
|
||||
(_, Uninitialized) => panic!("cannot move state to Uninitialized"),
|
||||
|
||||
|
|
@ -307,7 +307,7 @@ impl<T> EventLoopRunner<T> {
|
|||
self.call_new_events(false);
|
||||
}
|
||||
(Idle, Destroyed) => {
|
||||
self.call_event_handler(Event::LoopDestroyed);
|
||||
self.call_event_handler(Event::LoopExiting);
|
||||
}
|
||||
|
||||
(HandlingMainEvents, Idle) => {
|
||||
|
|
@ -317,7 +317,7 @@ impl<T> EventLoopRunner<T> {
|
|||
(HandlingMainEvents, Destroyed) => {
|
||||
self.call_event_handler(Event::MainEventsCleared);
|
||||
self.call_redraw_events_cleared();
|
||||
self.call_event_handler(Event::LoopDestroyed);
|
||||
self.call_event_handler(Event::LoopExiting);
|
||||
}
|
||||
|
||||
(Destroyed, _) => panic!("cannot move state from Destroyed"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue