don't display the confirm exit dialog twice

This commit is contained in:
Michael Becker 2020-09-20 01:03:36 -04:00
parent de321a3e39
commit 1221a7aacc
No known key found for this signature in database
GPG Key ID: 506F54899E2BFED7
2 changed files with 15 additions and 2 deletions

View File

@ -194,7 +194,7 @@ namespace UniversalEditor.UserInterface
MainWindow mw = (Application.Windows[i] as MainWindow);
if (mw == null) continue;
if (!mw.ConfirmExit())
if (!mw.Close())
{
e.Cancel = true;
break;

View File

@ -704,14 +704,27 @@ namespace UniversalEditor.UserInterface
}
return true;
}
private bool _UserClosed = false;
protected override void OnClosing(WindowClosingEventArgs e)
{
base.OnClosing(e);
if (e.CloseReason == WindowCloseReason.UserClosing)
if (e.CloseReason == WindowCloseReason.UserClosing || e.CloseReason == WindowCloseReason.ApplicationStop)
{
if (e.CloseReason == WindowCloseReason.UserClosing)
{
_UserClosed = true;
}
else if (e.CloseReason == WindowCloseReason.ApplicationStop && _UserClosed)
{
return;
}
if (!ConfirmExit())
{
_UserClosed = false;
e.Cancel = true;
}
}
}