MainWindow: Fix crash on closing, when other window is in editing or creating mode
All checks were successful
Test / Run tests (push) Successful in 2m1s

This commit is contained in:
2024-06-12 17:05:57 +02:00
parent 4483eb6a69
commit 70f8276808
2 changed files with 3 additions and 3 deletions

View File

@ -19,14 +19,14 @@ namespace Elwig.Windows {
private bool _isEditing; private bool _isEditing;
private bool _isCreating; private bool _isCreating;
protected bool IsEditing { public bool IsEditing {
get { return _isEditing; } get { return _isEditing; }
set { set {
_isEditing = value; _isEditing = value;
LockContext = IsEditing || IsCreating; LockContext = IsEditing || IsCreating;
} }
} }
protected bool IsCreating { public bool IsCreating {
get { return _isCreating; } get { return _isCreating; }
set { set {
_isCreating = value; _isCreating = value;

View File

@ -35,7 +35,7 @@ namespace Elwig.Windows {
} }
private void Window_Closing(object sender, CancelEventArgs evt) { private void Window_Closing(object sender, CancelEventArgs evt) {
if (App.NumWindows > 1 && !App.ForceShutdown) { if (App.NumWindows > 1 && !App.ForceShutdown && !App.Current.Windows.Cast<Window>().Any(w => ((w as AdministrationWindow)?.IsEditing ?? false) || ((w as AdministrationWindow)?.IsCreating ?? false))) {
var res = MessageBox.Show("Es sind noch weitere Fenster geöffnet.\nSollen alle Fenster geschlossen werden?", var res = MessageBox.Show("Es sind noch weitere Fenster geöffnet.\nSollen alle Fenster geschlossen werden?",
"Elwig beenden", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No); "Elwig beenden", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
if (res != MessageBoxResult.Yes) { if (res != MessageBoxResult.Yes) {