refactor(wry): emit RunEvent::Exit on Event::LoopDestroyed (#3785)

This commit is contained in:
Lucas Fernandes Nogueira
2022-03-27 16:22:34 -07:00
committed by GitHub
parent 9489963e00
commit 3c4ee7c997
2 changed files with 11 additions and 7 deletions

View File

@@ -0,0 +1,5 @@
---
"tauri-runtime-wry": patch
---
Emit `RunEvent::Exit` on `tao::event::Event::LoopDestroyed` instead of after `RunEvent::ExitRequested`.

View File

@@ -2300,14 +2300,10 @@ fn handle_event_loop<T: UserEvent>(
#[cfg(feature = "system-tray")]
tray_context,
} = context;
if *control_flow == ControlFlow::Exit {
return RunIteration {
window_count: windows.lock().expect("poisoned webview collection").len(),
};
if *control_flow != ControlFlow::Exit {
*control_flow = ControlFlow::Wait;
}
*control_flow = ControlFlow::Wait;
match event {
Event::NewEvents(StartCause::Init) => {
callback(RunEvent::Ready);
@@ -2321,6 +2317,10 @@ fn handle_event_loop<T: UserEvent>(
callback(RunEvent::MainEventsCleared);
}
Event::LoopDestroyed => {
callback(RunEvent::Exit);
}
Event::GlobalShortcutEvent(accelerator_id) => {
for (id, handler) in &*global_shortcut_manager_handle.listeners.lock().unwrap() {
if accelerator_id == *id {
@@ -2565,7 +2565,6 @@ fn on_window_close<'a, T: UserEvent>(
if !should_prevent {
*control_flow = ControlFlow::Exit;
callback(RunEvent::Exit);
}
}
Some(webview)