From d40461ec475859971a79182cd5c5b7d00abadd89 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 20 Aug 2016 10:52:59 +0200 Subject: [PATCH] BUG-2013 : This might fix the NRE as the events might not be in line with the cleaning up... --- Greenshot/Drawing/TextContainer.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Greenshot/Drawing/TextContainer.cs b/Greenshot/Drawing/TextContainer.cs index 002587b17..18a3e66f6 100644 --- a/Greenshot/Drawing/TextContainer.cs +++ b/Greenshot/Drawing/TextContainer.cs @@ -205,6 +205,10 @@ namespace Greenshot.Drawing void TextContainer_FieldChanged(object sender, FieldChangedEventArgs e) { + if (_textBox == null) + { + return; + } if (_textBox.Visible) { _textBox.Invalidate(); @@ -225,7 +229,7 @@ namespace Greenshot.Drawing } UpdateTextBoxFormat(); - if (_textBox != null && _textBox.Visible) + if (_textBox.Visible) { _textBox.Invalidate(); } @@ -360,6 +364,10 @@ namespace Greenshot.Drawing /// protected void UpdateFormat() { + if (_textBox == null) + { + return; + } string fontFamily = GetFieldValueAsString(FieldType.FONT_FAMILY); bool fontBold = GetFieldValueAsBool(FieldType.FONT_BOLD); bool fontItalic = GetFieldValueAsBool(FieldType.FONT_ITALIC); @@ -441,7 +449,7 @@ namespace Greenshot.Drawing { return; } - StringAlignment alignment = (StringAlignment)GetFieldValue(FieldType.TEXT_HORIZONTAL_ALIGNMENT); + var alignment = (StringAlignment)GetFieldValue(FieldType.TEXT_HORIZONTAL_ALIGNMENT); switch (alignment) { case StringAlignment.Near: @@ -455,7 +463,7 @@ namespace Greenshot.Drawing break; } - Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR); + var lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR); _textBox.ForeColor = lineColor; }