-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Window not destroyed after run_and_return #2892
Comments
Narrowed it down to commit cb77458 with git bisect.
|
Got it: diff --git a/crates/eframe/src/native/run.rs b/crates/eframe/src/native/run.rs
index a25ed4edd3b6..cfa047bbd812 100644
--- a/crates/eframe/src/native/run.rs
+++ b/crates/eframe/src/native/run.rs
@@ -175,6 +175,7 @@ fn run_and_return(
}
EventResult::Exit => {
tracing::debug!("Asking to exit event loop…");
+ winit_app.save_and_destroy();
*control_flow = ControlFlow::Exit;
return;
} Without this call the window refuses to destroy itself. From what I can see this call is hit before the one above it in: winit::event::Event::LoopDestroyed => {
// On Mac, Cmd-Q we get here and then `run_return` doesn't return (despite its name),
// so we need to save state now:
tracing::debug!("Received Event::LoopDestroyed - saving app state…");
winit_app.save_and_destroy();
*control_flow = ControlFlow::Exit;
return;
} and in fact reverting the above block to: winit::event::Event::LoopDestroyed => {
tracing::debug!("winit::event::Event::LoopDestroyed");
EventResult::Exit
} has no effect on the issue, or app behaviour for me. I'm taking a flying guess here and suspecting that the root cause of my issue is in the order of operations perhaps - where I'll do a PR. |
`EventResult::Exit` is hit before `Event::LoopDestroyed` is, and due to possibly some order of operations or drops the window is never destroyed on Linux. Adding a call to `winit_app.save_and_destroy();` where `EventResult::Exit` is checked solves this. Closes emilk#2892 Signed-off-by: Luke D. Jones <luke@ljones.dev>
`EventResult::Exit` is hit before `Event::LoopDestroyed` is, and due to possibly some order of operations or drops the window is never destroyed on Linux. Adding a call to `winit_app.save_and_destroy();` where `EventResult::Exit` is checked solves this. Closes emilk#2892 Signed-off-by: Luke D. Jones <luke@ljones.dev>
`EventResult::Exit` is hit before `Event::LoopDestroyed` is, and due to possibly some order of operations or drops the window is never destroyed on Linux. Adding a call to `winit_app.save_and_destroy();` where `EventResult::Exit` is checked solves this. Closes #2892 Signed-off-by: Luke D. Jones <luke@ljones.dev>
…lk#2895) `EventResult::Exit` is hit before `Event::LoopDestroyed` is, and due to possibly some order of operations or drops the window is never destroyed on Linux. Adding a call to `winit_app.save_and_destroy();` where `EventResult::Exit` is checked solves this. Closes emilk#2892 Signed-off-by: Luke D. Jones <luke@ljones.dev>
Hi, I still get the issue with egui 0.27. When wlosing the main window, the logs do show that the main viewport should be destroyed, but it isn't. (WIndows 11. Rust 1.79) 2024-04-08T14:53:45.875872Z DEBUG eframe::native::run: 176: Asking to exit event loop…
2024-04-08T14:53:45.891124Z DEBUG eframe::native::run: 89: Received Event::LoopExiting - saving app state…
2024-04-08T14:53:45.891610Z DEBUG eframe::native::run: 213: eframe window closed would they be a manuel aproach? maybe using on_exit |
Describe the bug
Somewhere between version 0.20.1 and version 0.21.0 the ability to re-run an app with
run_and_return
was broken such that the window is no-longer destroyed (using eframe).This can be reproduced using the serial windows example. In version 0.20.1 this example can close and destroy the window when the window bar X is clicked, but not when the "close" button is clicked. In version 0.21.x clicking the window X results in the same behaviour as the "close" button.
I initially thought it might be a winit issue but looking at the related issues there shows that egui is already using the found "workarounds".
A
git checkout 0.20.1 -- ./crates/eframe
shows that the issue lies within eframeThe text was updated successfully, but these errors were encountered: