diff --git a/PROMS/VEPROMS User Interface/Program.cs b/PROMS/VEPROMS User Interface/Program.cs index 44cab3fd..f21f5b86 100644 --- a/PROMS/VEPROMS User Interface/Program.cs +++ b/PROMS/VEPROMS User Interface/Program.cs @@ -22,17 +22,17 @@ namespace VEPROMS AttachConsole(ATTACH_PARENT_PROCESS); if (System.Diagnostics.Process.GetCurrentProcess().ProcessName.ToLower().EndsWith("vshost")) { - Application.Run(new frmVEPROMS()); + Application.Run(_myForm = new frmVEPROMS()); } else { Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); - Application.Run(new frmVEPROMS()); + Application.Run(_myForm = new frmVEPROMS()); } } - + static frmVEPROMS _myForm = null; // B2019-098: prevent looping between error & exit dialog static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { _log.Error("PROMS2010 Main UnhandledException", e.ExceptionObject as Exception); @@ -68,6 +68,7 @@ namespace VEPROMS string msg = string.Format("An error has occurred so the program will terminate. Please send the error log, {0}, to Volian.",dpath); if(!System.Environment.CommandLine.Contains("/P=")) MessageBox.Show(msg); + _myForm.ClosingWithError = true; Application.Exit(); } } diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 40e6d39a..30862a48 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -1168,6 +1168,7 @@ namespace VEPROMS return tc.PasteRTBItem(args.MyItemInfo, args.CopyStartID, args.PasteType, (int)args.Type); } private bool _RemoveFromPROMSWindowForms = true; + public bool ClosingWithError = false; // B2019-098: prevent looping between error & exit dialog private void frmVEPROMS_FormClosing(object sender, FormClosingEventArgs e) { // B2017-212 If the user uses the X button in Word to close the word attachment, PROMS thinks that the user wants to close out of PROMS as well @@ -1175,7 +1176,7 @@ namespace VEPROMS // B2017-214 added a null reference check // B2010-071 Since we cannot tell if the user click on the X in Word or the X in PROMS, ask if the current tab // should be closed or if we should exit PROMS or just Cancel to continue working - if (tc.SelectedDisplayTabItem != null && tc._MyDisplayTabItems.Count > 0) + if (!ClosingWithError && tc.SelectedDisplayTabItem != null && tc._MyDisplayTabItems.Count > 0) { DlgCloseTabsOrExit dctoe = new DlgCloseTabsOrExit(); // B2019-071 dialog to ask user if we are to close one tab or exit dctoe.ShowDialog();