diff options
author | Aaron Bockover <abock@microsoft.com> | 2019-07-03 23:10:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-03 23:10:44 +0300 |
commit | 412040da5abb7071dbfed4e741f03d54934946ca (patch) | |
tree | 496586d31f4147ebe3f647e9c7b577d53513f993 | |
parent | a5e6fa4c3fb65cebad4d0863dcf876913f3f6313 (diff) | |
parent | defa03ca98b2af2140ba5da48e4115d1234d5ba5 (diff) |
Merge pull request #8127 from mono/backport-pr-8097-to-release-8.2
[release-8.2] Fixes VSTS 935137: Null Reference Exceptions when disposing TextViewContent
-rw-r--r-- | main/src/addins/MonoDevelop.TextEditor/MonoDevelop.TextEditor/TextViewContent.cs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/main/src/addins/MonoDevelop.TextEditor/MonoDevelop.TextEditor/TextViewContent.cs b/main/src/addins/MonoDevelop.TextEditor/MonoDevelop.TextEditor/TextViewContent.cs index 24bd8b38eb..01dee29c5b 100644 --- a/main/src/addins/MonoDevelop.TextEditor/MonoDevelop.TextEditor/TextViewContent.cs +++ b/main/src/addins/MonoDevelop.TextEditor/MonoDevelop.TextEditor/TextViewContent.cs @@ -321,12 +321,22 @@ namespace MonoDevelop.TextEditor protected virtual void UnsubscribeFromEvents () { - sourceEditorOptions.Changed -= UpdateTextEditorOptions; - if (TextDocument != null) { + if (sourceEditorOptions != null) + sourceEditorOptions.Changed -= UpdateTextEditorOptions; + + if (TextDocument != null) TextDocument.DirtyStateChanged -= HandleTextDocumentDirtyStateChanged; + + if (TextBuffer != null) TextBuffer.Changed -= HandleTextBufferChanged; + + // while this actually generates a "warning" about potentially comparing value types, + // we can be fairly confident that's not actually going to happen - and while the correct + // change would be to ensure TView is a "class", that's too big of a change to try and + // and combat this bug with. + // In addition, this will get JITTed into a cast to Object and a check for null. + if (TextView != null && TextView.Options != null) TextView.Options.OptionChanged -= TextBufferOptionsChanged; - } } void UpdateBufferOptions () |