-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Fix desktop lifetime non-mainwindow cancellation #17059
Fix desktop lifetime non-mainwindow cancellation #17059
Conversation
…downMode == ShutdownMode.OnMainWindowClose
You can test this PR using the following package version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about ignoring WindowClosingEventArgs.Cancel
in Window.CloseCore
on shutdown (and document it) for the secondary windows, effectively closing them (and matching WPF)?
Currently, the extra windows won't ever have a chance of running any cleanup code.
src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs
Show resolved
Hide resolved
But that's how it works in this PR right now. Sorry, somehow I missed these review comments before. |
You can test this PR using the following package version. |
Sorry, I wasn't very clear. (My initial comment mentioned ignoring AFAICT, in WPF, both |
You can test this PR using the following package version. |
@MrJul Window.Closed event is raised properly now. |
You can test this PR using the following package version. |
Nice! As a bonus I find the new code to be easier to follow :) |
* Only check MainWindow visiblity in DoShutdown cancellation, when ShutdownMode == ShutdownMode.OnMainWindowClose * Raise WindowClosedEvent event AFTER IsVisible/_shown properties were updated * Add OnMainWindowClose cancellation tests * Assert that Closing event was actually raised. * Re-do fix by forcing window closing * Forced .Shutdown() should also raise Window.Closed events, and not ignore them
They were swapped in #17059 which caused problems for Outsystems. Temporarily reverting this for them until we decide what to do long-term.
What does the pull request do?
That's a rather old bug which was surfaced after my previous fix: #15438
Current PR makes Avalonia behave closer to WPF:
When ShutdownMode is set to OnMainWindowClose, only main window can cancel shutdown.
What is the current behavior?
Any window can cancel app shutdown, even after main window was closed.
What is the updated/expected behavior with this PR?
Only main window shutdown cancellation is respected, when ShutdownMode=OnMainWindowClose
Checklist
Breaking changes
Possible behavioral breaking change. At the same time, new behavior might be an expected one for WPF developers.