From 2c15add602dfd030c19c26954280382a935554c7 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 14 Jul 2017 18:30:57 +0000 Subject: [PATCH] Added Try/Catch as part of B2017-143 fix to prevent PROMS from crashing B2017-143 Print was disposing fonts that are save in a static dictionary, causing editor display problems after printing a procedure. --- PROMS/Volian.Controls.Library/EditItem.cs | 11 ++++++++++- PROMS/Volian.Svg.Library/SvgFontSettings.cs | 8 +++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/PROMS/Volian.Controls.Library/EditItem.cs b/PROMS/Volian.Controls.Library/EditItem.cs index acb852c6..37a719e8 100644 --- a/PROMS/Volian.Controls.Library/EditItem.cs +++ b/PROMS/Volian.Controls.Library/EditItem.cs @@ -3715,7 +3715,16 @@ namespace Volian.Controls.Library //g.DrawLine(Pens.DarkGreen, MyStepRTB.Location.X - 7, 0, MyStepRTB.Location.X - 7, this.Height); //g.DrawString(TabText, MyItemInfo.MyTab.MyFont.WindowsFont, Brushes.Black, new RectangleF(new PointF(Convert.ToSingle(TabLocation.X), Convert.ToSingle(TabLocation.Y)), MyStepPanel.MyStepPanelSettings.NumberSize), StringFormat.GenericDefault); Font myWFont = (MyItemInfo.MyTab != null) ? MyItemInfo.MyTab.MyFont.WindowsFont : MyItemInfo.FormatStepData.Font.WindowsFont; - g.DrawString(TabText, myWFont, Brushes.Black, new RectangleF(new PointF(Convert.ToSingle(TabLocation.X), Convert.ToSingle(TabLocation.Y)), this.Size), StringFormat.GenericDefault); + + // added Try/Catch when working on B2017-143, kept in to prevent PROMS from crashing after printing a procedure that has a seq tab with a different font style + try + { + g.DrawString(TabText, myWFont, Brushes.Black, new RectangleF(new PointF(Convert.ToSingle(TabLocation.X), Convert.ToSingle(TabLocation.Y)), this.Size), StringFormat.GenericDefault); + } + catch (Exception ex) + { + _MyLog.Warn("EditItem DrawString", ex); + } //g.DrawLine(Pens.DarkGreen, lblTab.Location.X, 0, lblTab.Location.X, this.Height); //g.DrawLine(Pens.DarkGreen, MyStepRTB.Location.X, 0, MyStepRTB.Location.X, this.Height); diff --git a/PROMS/Volian.Svg.Library/SvgFontSettings.cs b/PROMS/Volian.Svg.Library/SvgFontSettings.cs index f6836138..d151c16e 100644 --- a/PROMS/Volian.Svg.Library/SvgFontSettings.cs +++ b/PROMS/Volian.Svg.Library/SvgFontSettings.cs @@ -110,7 +110,13 @@ namespace Volian.Svg.Library } set { - if (_Font != null) _Font.Dispose(); + // This was disposing fonts that are saved in our static dictionary. + // caused problems with the step editor display after printing (found with Wolf Creek Chem procedure RW-G02 Step 6.1.17) - jsj 7/14/2017 + //if (_Font != null) + //{ + // Console.WriteLine("font dispose {0}, {1}", _Font, _Font.Style); + // //_Font.Dispose(); + //} if (value != null) { _FontFamily = value.FontFamily.Name;