B2019-098: Upon error and clicking ok on error dialog, the next dialog, for how to close, loops

This commit is contained in:
Kathy Ruffing 2019-07-26 13:36:16 +00:00
parent b7d3a4628e
commit ab656a0876
2 changed files with 6 additions and 4 deletions

View File

@ -22,17 +22,17 @@ namespace VEPROMS
AttachConsole(ATTACH_PARENT_PROCESS); AttachConsole(ATTACH_PARENT_PROCESS);
if (System.Diagnostics.Process.GetCurrentProcess().ProcessName.ToLower().EndsWith("vshost")) if (System.Diagnostics.Process.GetCurrentProcess().ProcessName.ToLower().EndsWith("vshost"))
{ {
Application.Run(new frmVEPROMS()); Application.Run(_myForm = new frmVEPROMS());
} }
else else
{ {
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); 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) static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{ {
_log.Error("PROMS2010 Main UnhandledException", e.ExceptionObject as Exception); _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); 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=")) if(!System.Environment.CommandLine.Contains("/P="))
MessageBox.Show(msg); MessageBox.Show(msg);
_myForm.ClosingWithError = true;
Application.Exit(); Application.Exit();
} }
} }

View File

@ -1168,6 +1168,7 @@ namespace VEPROMS
return tc.PasteRTBItem(args.MyItemInfo, args.CopyStartID, args.PasteType, (int)args.Type); return tc.PasteRTBItem(args.MyItemInfo, args.CopyStartID, args.PasteType, (int)args.Type);
} }
private bool _RemoveFromPROMSWindowForms = true; private bool _RemoveFromPROMSWindowForms = true;
public bool ClosingWithError = false; // B2019-098: prevent looping between error & exit dialog
private void frmVEPROMS_FormClosing(object sender, FormClosingEventArgs e) 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 // 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 // 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 // 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 // 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 DlgCloseTabsOrExit dctoe = new DlgCloseTabsOrExit(); // B2019-071 dialog to ask user if we are to close one tab or exit
dctoe.ShowDialog(); dctoe.ShowDialog();