From 09f7dec79b2ab6b83065e79afa2e9e924a0d4fe2 Mon Sep 17 00:00:00 2001 From: Alexander Sloutsky Date: Sat, 6 Jun 2020 13:49:20 +0300 Subject: [PATCH] Fix null-reference exception in TextAreaAutomationPeer - that was randomly occuring in the application. --- ICSharpCode.AvalonEdit/Editing/TextAreaAutomationPeer.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.AvalonEdit/Editing/TextAreaAutomationPeer.cs b/ICSharpCode.AvalonEdit/Editing/TextAreaAutomationPeer.cs index 1af35ac..f8d3878 100644 --- a/ICSharpCode.AvalonEdit/Editing/TextAreaAutomationPeer.cs +++ b/ICSharpCode.AvalonEdit/Editing/TextAreaAutomationPeer.cs @@ -114,8 +114,11 @@ namespace ICSharpCode.AvalonEdit.Editing return this; if (patternInterface == PatternInterface.Scroll) { TextEditor editor = TextArea.GetService(typeof(TextEditor)) as TextEditor; - if (editor != null) - return FromElement(editor).GetPattern(patternInterface); + if (editor != null) { + var fromElement = FromElement(editor); + if (fromElement != null) + fromElement.GetPattern(patternInterface); + } } return base.GetPattern(patternInterface); }