From 1221a7aacc06408ea0029b68efc0643fa0783e5b Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Sun, 20 Sep 2020 01:03:36 -0400 Subject: [PATCH] don't display the confirm exit dialog twice --- Libraries/UniversalEditor.UserInterface/Engine.cs | 2 +- .../UniversalEditor.UserInterface/MainWindow.cs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Libraries/UniversalEditor.UserInterface/Engine.cs b/Libraries/UniversalEditor.UserInterface/Engine.cs index 9a4b131b..fe581f4b 100644 --- a/Libraries/UniversalEditor.UserInterface/Engine.cs +++ b/Libraries/UniversalEditor.UserInterface/Engine.cs @@ -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; diff --git a/Libraries/UniversalEditor.UserInterface/MainWindow.cs b/Libraries/UniversalEditor.UserInterface/MainWindow.cs index caad510b..a52be896 100644 --- a/Libraries/UniversalEditor.UserInterface/MainWindow.cs +++ b/Libraries/UniversalEditor.UserInterface/MainWindow.cs @@ -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; + } } }