You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue Description
When using nannou for developing applications on macOS, I've observed that pressing cmd-Q causes the application to exit immediately. It appears that the window close request event might be handled before nannou's own event loop gets the chance, thus bypassing any custom exit handlers I've set up.
Steps to Reproduce:
Set up a basic nannou application.
Implement a custom exit handler by implementing Drop for Model.
Run the application on macOS.
Sanity check: press esc to verify that the exit handler does run when exiting with esc.
Press cmd-Q to quit the application. The exit handler does not run in this situation.
Here’s a minimal example:
use nannou::prelude::*;
fn main() {
nannou::app(model)
.update(update)
.simple_window(view)
.run();
}
struct Model {}
impl Drop for Model {
fn drop(&mut self) {
println!("saving some important state!");
}
}
fn model(_app: &App) -> Model {
Model {}
}
fn update(_app: &App, _model: &mut Model, _update: Update) {
}
fn view(_app: &App, _model: &Model, frame: Frame){
frame.clear(PURPLE);
}
Expected Behavior: The application should run the custom exit handler before closing, printing “saving some important state!” to console.
Actual Behavior: The application exits immediately without running the custom exit handler.
Potential Impact:
For applications that need to perform critical cleanup tasks or save state before exiting, this behavior could lead to data loss or other unintended side effects. I’d like to use nannou to build a kind of an editor application that auto-saves the project on exit, but not being able to override cmd-Q behavior is a major problem for my usecase.
Suggested Solution:
It would be beneficial if nannou could expose or forward the window close request event to the application before actually closing it, allowing developers to decide how to handle this situation.
The text was updated successfully, but these errors were encountered:
Issue Description
When using nannou for developing applications on macOS, I've observed that pressing cmd-Q causes the application to exit immediately. It appears that the window close request event might be handled before nannou's own event loop gets the chance, thus bypassing any custom exit handlers I've set up.
Steps to Reproduce:
Here’s a minimal example:
Expected Behavior: The application should run the custom exit handler before closing, printing “saving some important state!” to console.
Actual Behavior: The application exits immediately without running the custom exit handler.
Potential Impact:
For applications that need to perform critical cleanup tasks or save state before exiting, this behavior could lead to data loss or other unintended side effects. I’d like to use nannou to build a kind of an editor application that auto-saves the project on exit, but not being able to override cmd-Q behavior is a major problem for my usecase.
Suggested Solution:
It would be beneficial if nannou could expose or forward the window close request event to the application before actually closing it, allowing developers to decide how to handle this situation.
The text was updated successfully, but these errors were encountered: