-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Graceful shutdown of native eframe #814
Comments
I was wanting this functionality a while ago (to allow time for network connections to close cleanly while still showing UI progress feedback). I got as far as determining that AFAICT the reason this wasn't currently possible was due to treating Line 562 in 19766bf
I did not get as far as writing this up until now, however. :) As I understand it, to enable graceful shutdown we'd need to treat |
Is this already implemented? This example: https://github.com/emilk/egui/tree/master/examples/confirm_exit seems to work. |
the example shows how to close the application using this issue is more about intercepting an external close event (clicking red |
It intercepts! The on_close_event function defined when implementing the eframe app is invoked when a user attempts to close the window. In this case, the function flips a boolean that shows the exit dialog to the user. When attempting to close the window of that demo on my (Linux/Wayland) machine, instead of the window closing, I see the dialog. Try it on yours 😁 |
oh.. you are right. i didn't know about on_close_event until now. I guess this issue is already solved then. |
Sparked by #813
There are two user stories we want to support:
When a user closes the native eframe window (e.g. by clicking the X or pressing Ctrl-F4/Cmd-Q)…
…the egui app should continue and show a "Do you want to save your work" popup (using egui).
…the native window should close immediately, but the app should be able to take its time to save data to disk, etc.
For the first case
eframe
would need to communicate the closing as an event to the App rather than shutting down directly, and then have the app telleframe
when it is actually time to quit.For the second case: currently if
App::on_exit
is slow, the native window will linger, frozen and unresponsive (bad). The fix is probably as simple as moving around some code inegui_glium
andegui_glow
.The text was updated successfully, but these errors were encountered: