From 834d5bf38793e6bf8b471e53cab30b989c6abace Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Sat, 29 Oct 2005 13:24:56 +0000 Subject: [PATCH] Fixed ObjectDisposedException generated when running XSL transform after splitting the XSLT Output window. The TextAreaControl/TextArea classes were not removing document event handlers when disposed. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@653 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Gui/TextArea.cs | 11 +++++++++-- .../Project/Src/Gui/TextAreaControl.cs | 12 ++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs index 728ccbd525..2993242d1b 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs @@ -56,6 +56,8 @@ namespace ICSharpCode.TextEditor SelectionManager selectionManager; Caret caret; + bool disposed; + public TextEditorControl MotherTextEditorControl { get { return motherTextEditorControl; @@ -727,12 +729,17 @@ namespace ICSharpCode.TextEditor // ++Caret.DesiredColumn; } - protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { - Caret.Dispose(); + if (!disposed) { + disposed = true; + caret.PositionChanged -= new EventHandler(SearchMatchingBracket); + Document.TextContentChanged -= new EventHandler(TextContentChanged); + Document.FoldingManager.FoldingsChanged -= new EventHandler(DocumentFoldingsChanged); + caret.Dispose(); + } } } diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaControl.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaControl.cs index c2a2ed9c71..918dd5681b 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaControl.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaControl.cs @@ -39,6 +39,7 @@ namespace ICSharpCode.TextEditor HScrollBar hScrollBar = new HScrollBar(); TextArea textArea; bool doHandleMousewheel = true; + bool disposed; public TextArea TextArea { get { @@ -110,6 +111,17 @@ namespace ICSharpCode.TextEditor SetStyle(ControlStyles.Selectable, true); } + protected override void Dispose(bool disposing) + { + if (disposing) { + if (!disposed) { + disposed = true; + Document.DocumentChanged -= new DocumentEventHandler(AdjustScrollBars); + } + } + base.Dispose(disposing); + } + protected override void OnResize(System.EventArgs e) { base.OnResize(e);