-
-
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
TryShutdown combined with unconditional e.Cancel = true
stucks in the infinite loop
#15533
Comments
@robloo I thought it's a regression from #15438, but I am not sure anymore. First of all, this specific code you provided has two issues:
This loop from #2 is what was changed between versions. In 11.1-beta1 and before we had an issue that In 11.1-beta2 it was fixed, and |
I am going to remove "regression" label, as it's not an actual regression, but app relied on the previously broken behavior. If you need to force app to be closed (ignoring Window.Closing event), you need to use But I will keep this issue opened, as:
Issue title should be adjusted too. |
e.Cancel = true
stucks in the infinite loop
Or we can create another issue instead, and close this one. |
Yes, there are dialogs in the full code. Note that I would have expected intercepting Window close to be separate than application shutdown so TryShutdown() is not actually called within TryShutdown(). In other words, when a Window is closing itself I would expect this to occur BEFORE the application shutdown process. Only once all windows are closed would Avalonia then trigger application shutdown. What this means is if you stop a window from closing TryShutdown() is never actually called because the application shutdown process never started. This makes more sense to me and I suspect is how WPF/UWP work in this area (this code was ported from UWP/WinUI where it worked there).
Again, I am handling window close which I would expect to occur before any actual shutdown. So I have a few high-level thoughts here: The distinction in Avalonia between Application, TopLevel and Window is almost certainly confusing/wrong in several cases.
Yea, I wasn't aware we had two different methods for this and in my code just using I would leave this open for now as we discuss the above. We should also document a behavioral breaking change for 11.1 in this area. |
Describe the bug
Intercepting window close and then manually calling IClassicDesktopStyleApplicationLifetime.TryShutdown() no longer works in 11.1-beta2
To Reproduce
The main Window intercepts closing:
Then, if the user confirms they wish to close without saving, it continues. Note that a lot of code is removed here and only the bare minimum kept to show the code paths taken.
Expected behavior
Desktop apps should be able to shutdown themselves
Avalonia version
11.1-beta2
OS
Windows
Additional context
This has worked since 11.0 previews (for over a year) and only now seems broken in 11.1-beta2.
The text was updated successfully, but these errors were encountered: