Browse Source

Ported Fidalgo rev. 2115 (Ivo Kovacka): fixed some minor problems where object were staying in memory (missing dispose calls, event handlers not being deregistered).

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@891 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
aa02f22658
  1. 24
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/DefaultServiceContainer.cs
  2. 11
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/ToolboxService.cs
  3. 2
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs
  4. 26
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/Selection/SelectionManager.cs
  5. 15
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/Caret.cs
  6. 10
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/GutterMargin.cs
  7. 21
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs
  8. 4
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaClipboardHandler.cs
  9. 31
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaControl.cs
  10. 28
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextEditorControl.cs
  11. 2
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextEditorControlBase.cs
  12. 8
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs
  13. 1
      src/Main/Base/Project/Src/Gui/AbstractBaseViewContent.cs
  14. 1
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs
  15. 13
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs
  16. 6
      src/Main/Base/Project/Src/Project/AbstractProject.cs
  17. 2
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/QuickClassBrowserPanel.cs
  18. 10
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs
  19. 18
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs

24
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/DefaultServiceContainer.cs

@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
using System;
using System.Reflection;
using System.Collections;
using System.Collections.Specialized;
using System.Drawing;
using System.ComponentModel;
using System.ComponentModel.Design;
@ -20,7 +19,8 @@ namespace ICSharpCode.FormsDesigner.Services @@ -20,7 +19,8 @@ namespace ICSharpCode.FormsDesigner.Services
public class DefaultServiceContainer : IServiceContainer, IDisposable
{
IServiceContainer serviceContainer;
ArrayList services = new ArrayList();
Hashtable services = new Hashtable();
bool inDispose = false;
public DefaultServiceContainer()
{
@ -35,12 +35,13 @@ namespace ICSharpCode.FormsDesigner.Services @@ -35,12 +35,13 @@ namespace ICSharpCode.FormsDesigner.Services
#region System.IDisposable interface implementation
public virtual void Dispose()
{
foreach (object o in services) {
if (o == this) {
inDispose = true;
foreach (DictionaryEntry o in services) {
if (o.Value == this) {
continue;
}
// || o.GetType().Assembly != Assembly.GetCallingAssembly()
IDisposable disposeMe = o as IDisposable;
IDisposable disposeMe = o.Value as IDisposable;
if (disposeMe != null) {
try {
disposeMe.Dispose();
@ -51,18 +52,27 @@ namespace ICSharpCode.FormsDesigner.Services @@ -51,18 +52,27 @@ namespace ICSharpCode.FormsDesigner.Services
}
services.Clear();
services = null;
inDispose = false;
}
#endregion
#region System.ComponentModel.Design.IServiceContainer interface implementation
public void RemoveService(System.Type serviceType, bool promote)
{
if (inDispose)
return;
serviceContainer.RemoveService(serviceType, promote);
if (services.Contains(serviceType))
services.Remove(serviceType);
}
public void RemoveService(System.Type serviceType)
{
if (inDispose == true)
return;
serviceContainer.RemoveService(serviceType);
if (services.Contains(serviceType))
services.Remove(serviceType);
}
public void AddService(System.Type serviceType, System.ComponentModel.Design.ServiceCreatorCallback callback, bool promote)
@ -83,7 +93,7 @@ namespace ICSharpCode.FormsDesigner.Services @@ -83,7 +93,7 @@ namespace ICSharpCode.FormsDesigner.Services
{
if (IsServiceMissing(serviceType)) {
serviceContainer.AddService(serviceType, serviceInstance, promote);
services.Add(serviceInstance);
services.Add(serviceType, serviceInstance);
}
}
@ -91,7 +101,7 @@ namespace ICSharpCode.FormsDesigner.Services @@ -91,7 +101,7 @@ namespace ICSharpCode.FormsDesigner.Services
{
if (IsServiceMissing(serviceType)) {
serviceContainer.AddService(serviceType, serviceInstance);
services.Add(serviceInstance);
services.Add(serviceType, serviceInstance);
}
}
#endregion

11
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/ToolboxService.cs

@ -412,10 +412,21 @@ namespace ICSharpCode.FormsDesigner.Services @@ -412,10 +412,21 @@ namespace ICSharpCode.FormsDesigner.Services
public void RemoveCreator(string format)
{
RemoveCreator(format, null);
}
public void RemoveCreator(string format, IDesignerHost host)
{
if (host == null) {
creators.Remove(format);
} else {
HybridDictionary creatorsDict = creatorsByHost[host] as HybridDictionary;
if (creatorsDict != null) {
creatorsDict.Remove(format);
if (creatorsDict.Count == 0)
creatorsByHost.Remove(host);
}
}
}
public void RemoveToolboxItem(ToolboxItem toolboxItem)

2
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs

@ -271,6 +271,7 @@ namespace ICSharpCode.TextEditor.Document @@ -271,6 +271,7 @@ namespace ICSharpCode.TextEditor.Document
}
document.RequestUpdate(new TextAreaUpdate(TextAreaUpdateType.WholeTextArea));
document.CommitUpdate();
currentLine = null;
}
bool MarkTokensInLine(IDocument document, int lineNumber, ref bool spanChanged)
@ -412,6 +413,7 @@ namespace ICSharpCode.TextEditor.Document @@ -412,6 +413,7 @@ namespace ICSharpCode.TextEditor.Document
}
document.CommitUpdate();
currentLine = null;
}
// Span state variables

26
src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/Selection/SelectionManager.cs

@ -16,7 +16,7 @@ namespace ICSharpCode.TextEditor.Document @@ -16,7 +16,7 @@ namespace ICSharpCode.TextEditor.Document
/// <summary>
/// This class manages the selections in a document.
/// </summary>
public class SelectionManager
public class SelectionManager : IDisposable
{
IDocument document;
List<ISelection> selectionCollection = new List<ISelection>();
@ -71,6 +71,14 @@ namespace ICSharpCode.TextEditor.Document @@ -71,6 +71,14 @@ namespace ICSharpCode.TextEditor.Document
document.DocumentChanged += new DocumentEventHandler(DocumentChanged);
}
public void Dispose()
{
if (this.document != null) {
document.DocumentChanged -= new DocumentEventHandler(DocumentChanged);
this.document = null;
}
}
void DocumentChanged(object sender, DocumentEventArgs e)
{
if (e.Text == null) {
@ -92,7 +100,7 @@ namespace ICSharpCode.TextEditor.Document @@ -92,7 +100,7 @@ namespace ICSharpCode.TextEditor.Document
{
// autoClearSelection = false;
if (selection != null) {
if (SelectionCollection.Count == 1 &&
if (SelectionCollection.Count == 1 &&
selection.StartPosition == SelectionCollection[0].StartPosition &&
selection.EndPosition == SelectionCollection[0].EndPosition ) {
return;
@ -153,7 +161,7 @@ namespace ICSharpCode.TextEditor.Document @@ -153,7 +161,7 @@ namespace ICSharpCode.TextEditor.Document
} else {
if (oldPosition == selection.StartPosition) {
if (GreaterEqPos(newPosition, selection.EndPosition)) {
if (selection.StartPosition != selection.EndPosition ||
if (selection.StartPosition != selection.EndPosition ||
selection.EndPosition != newPosition) {
selection.StartPosition = selection.EndPosition;
selection.EndPosition = newPosition;
@ -180,13 +188,13 @@ namespace ICSharpCode.TextEditor.Document @@ -180,13 +188,13 @@ namespace ICSharpCode.TextEditor.Document
changed = true;
}
}
}
}
}
// if (GreaterEqPos(selection.StartPosition, min) && GreaterEqPos(selection.EndPosition, max)) {
// if (oldIsGreater) {
// selection.StartPosition = min;
// } else {
// } else {
// selection.StartPosition = max;
// }
// } else {
@ -216,7 +224,7 @@ namespace ICSharpCode.TextEditor.Document @@ -216,7 +224,7 @@ namespace ICSharpCode.TextEditor.Document
/// </remarks>
public void ClearSelection()
{
ClearWithoutUpdate();
ClearWithoutUpdate();
document.CommitUpdate();
}
@ -247,7 +255,7 @@ namespace ICSharpCode.TextEditor.Document @@ -247,7 +255,7 @@ namespace ICSharpCode.TextEditor.Document
}
ClearSelection();
if (offset >= 0) {
// TODO:
// TODO:
// document.Caret.Offset = offset;
}
if (offset != -1) {
@ -266,8 +274,8 @@ namespace ICSharpCode.TextEditor.Document @@ -266,8 +274,8 @@ namespace ICSharpCode.TextEditor.Document
bool SelectionsOverlap(ISelection s1, ISelection s2)
{
return (s1.Offset <= s2.Offset && s2.Offset <= s1.Offset + s1.Length) ||
(s1.Offset <= s2.Offset + s2.Length && s2.Offset + s2.Length <= s1.Offset + s1.Length) ||
(s1.Offset >= s2.Offset && s1.Offset + s1.Length <= s2.Offset + s2.Length);
(s1.Offset <= s2.Offset + s2.Length && s2.Offset + s2.Length <= s1.Offset + s1.Length) ||
(s1.Offset >= s2.Offset && s1.Offset + s1.Length <= s2.Offset + s2.Length);
}
/// <remarks>

15
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/Caret.cs

@ -132,6 +132,15 @@ namespace ICSharpCode.TextEditor @@ -132,6 +132,15 @@ namespace ICSharpCode.TextEditor
textArea.LostFocus += new EventHandler(LostFocus);
}
public void Dispose()
{
textArea.GotFocus -= new EventHandler(GotFocus);
textArea.LostFocus -= new EventHandler(LostFocus);
textArea = null;
// DestroyCaret();
// caretCreated = false;
}
public Point ValidatePosition(Point pos)
{
int line = Math.Max(0, Math.Min(textArea.Document.TotalNumberOfLines - 1, pos.Y));
@ -259,12 +268,6 @@ namespace ICSharpCode.TextEditor @@ -259,12 +268,6 @@ namespace ICSharpCode.TextEditor
}
}
public void Dispose()
{
// DestroyCaret();
// caretCreated = false;
}
#region Native caret functions
[DllImport("User32.dll")]
static extern bool CreateCaret(IntPtr hWnd, int hBitmap, int nWidth, int nHeight);

10
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/GutterMargin.cs

@ -21,7 +21,7 @@ namespace ICSharpCode.TextEditor @@ -21,7 +21,7 @@ namespace ICSharpCode.TextEditor
/// <summary>
/// This class views the line numbers and folding markers.
/// </summary>
public class GutterMargin : AbstractMargin
public class GutterMargin : AbstractMargin, IDisposable
{
StringFormat numberStringFormat = (StringFormat)StringFormat.GenericTypographic.Clone();
@ -34,6 +34,10 @@ namespace ICSharpCode.TextEditor @@ -34,6 +34,10 @@ namespace ICSharpCode.TextEditor
cursorStream.Close();
}
public void Dispose()
{
numberStringFormat.Dispose();
}
public override Cursor Cursor {
get {
@ -59,7 +63,7 @@ namespace ICSharpCode.TextEditor @@ -59,7 +63,7 @@ namespace ICSharpCode.TextEditor
{
numberStringFormat.LineAlignment = StringAlignment.Far;
numberStringFormat.FormatFlags = StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.FitBlackBox |
StringFormatFlags.NoWrap | StringFormatFlags.NoClip;
StringFormatFlags.NoWrap | StringFormatFlags.NoClip;
}
public override void Paint(Graphics g, Rectangle rect)
@ -151,7 +155,7 @@ namespace ICSharpCode.TextEditor @@ -151,7 +155,7 @@ namespace ICSharpCode.TextEditor
}
}
}
textArea.Caret.Position = realmousepos;
}
} else {

21
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextArea.cs

@ -614,9 +614,10 @@ namespace ICSharpCode.TextEditor @@ -614,9 +614,10 @@ namespace ICSharpCode.TextEditor
motherTextEditorControl.EndUpdate();
}
public bool EnableCutOrPaste
{
public bool EnableCutOrPaste {
get {
if (motherTextAreaControl == null)
return false;
if (TextEditorProperties.UseCustomLine == true) {
if (SelectionManager.HasSomethingSelected == true) {
if (Document.CustomLineManager.IsReadOnly(SelectionManager.SelectionCollection[0], false))
@ -759,10 +760,22 @@ namespace ICSharpCode.TextEditor @@ -759,10 +760,22 @@ namespace ICSharpCode.TextEditor
if (disposing) {
if (!disposed) {
disposed = true;
caret.PositionChanged -= new EventHandler(SearchMatchingBracket);
if (caret != null) {
caret.PositionChanged -= new EventHandler(SearchMatchingBracket);
caret.Dispose();
}
if (selectionManager != null) {
selectionManager.Dispose();
}
Document.TextContentChanged -= new EventHandler(TextContentChanged);
Document.FoldingManager.FoldingsChanged -= new EventHandler(DocumentFoldingsChanged);
caret.Dispose();
motherTextAreaControl = null;
motherTextEditorControl = null;
foreach (AbstractMargin margin in leftMargins) {
if (margin is IDisposable)
(margin as IDisposable).Dispose();
}
textView.Dispose();
}
}
}

4
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaClipboardHandler.cs

@ -32,7 +32,7 @@ namespace ICSharpCode.TextEditor @@ -32,7 +32,7 @@ namespace ICSharpCode.TextEditor
public bool EnableCut {
get {
return true; //textArea.SelectionManager.HasSomethingSelected;
return textArea.EnableCutOrPaste; //textArea.SelectionManager.HasSomethingSelected;
}
}
@ -54,7 +54,7 @@ namespace ICSharpCode.TextEditor @@ -54,7 +54,7 @@ namespace ICSharpCode.TextEditor
public bool EnableDelete {
get {
return textArea.SelectionManager.HasSomethingSelected;
return textArea.SelectionManager.HasSomethingSelected && textArea.EnableCutOrPaste;
}
}

31
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaControl.cs

@ -62,13 +62,17 @@ namespace ICSharpCode.TextEditor @@ -62,13 +62,17 @@ namespace ICSharpCode.TextEditor
[Browsable(false)]
public IDocument Document {
get {
return motherTextEditorControl.Document;
if (motherTextEditorControl != null)
return motherTextEditorControl.Document;
return null;
}
}
public ITextEditorProperties TextEditorProperties {
get {
return motherTextEditorControl.TextEditorProperties;
if (motherTextEditorControl != null)
return motherTextEditorControl.TextEditorProperties;
return null;
}
}
@ -117,6 +121,19 @@ namespace ICSharpCode.TextEditor @@ -117,6 +121,19 @@ namespace ICSharpCode.TextEditor
if (!disposed) {
disposed = true;
Document.DocumentChanged -= new DocumentEventHandler(AdjustScrollBars);
motherTextEditorControl = null;
if (vScrollBar != null) {
vScrollBar.Dispose();
vScrollBar = null;
}
if (hScrollBar != null) {
hScrollBar.Dispose();
hScrollBar = null;
}
if (hRuler != null) {
hRuler.Dispose();
hRuler = null;
}
}
}
base.Dispose(disposing);
@ -133,11 +150,11 @@ namespace ICSharpCode.TextEditor @@ -133,11 +150,11 @@ namespace ICSharpCode.TextEditor
int y = 0;
int h = 0;
if (hRuler != null) {
hRuler.Bounds = new Rectangle(0,
0,
hRuler.Bounds = new Rectangle(0,
0,
Width - SystemInformation.HorizontalScrollBarArrowWidth,
textArea.TextView.FontHeight);
y = hRuler.Bounds.Bottom;
h = hRuler.Bounds.Height;
}
@ -151,9 +168,9 @@ namespace ICSharpCode.TextEditor @@ -151,9 +168,9 @@ namespace ICSharpCode.TextEditor
public void SetScrollBarBounds()
{
vScrollBar.Bounds = new Rectangle(textArea.Bounds.Right, 0, SystemInformation.HorizontalScrollBarArrowWidth, Height - SystemInformation.VerticalScrollBarArrowHeight);
hScrollBar.Bounds = new Rectangle(0,
hScrollBar.Bounds = new Rectangle(0,
textArea.Bounds.Bottom,
Width - SystemInformation.HorizontalScrollBarArrowWidth,
Width - SystemInformation.HorizontalScrollBarArrowWidth,
SystemInformation.VerticalScrollBarArrowHeight);
}
public void AdjustScrollBars(object sender, DocumentEventArgs e)

28
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextEditorControl.cs

@ -23,7 +23,7 @@ using System.Text; @@ -23,7 +23,7 @@ using System.Text;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.TextEditor.Actions;
namespace ICSharpCode.TextEditor
{
/// <summary>
@ -168,6 +168,32 @@ namespace ICSharpCode.TextEditor @@ -168,6 +168,32 @@ namespace ICSharpCode.TextEditor
Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(name);
}
protected override void Dispose(bool disposing)
{
if (disposing) {
if (printDocument != null) {
printDocument.BeginPrint -= new PrintEventHandler(this.BeginPrint);
printDocument.PrintPage -= new PrintPageEventHandler(this.PrintPage);
printDocument = null;
}
Document.UndoStack.ClearAll();
Document.UpdateCommited -= new EventHandler(CommitUpdateRequested);
if (textAreaPanel != null) {
if (secondaryTextArea != null) {
secondaryTextArea.Dispose();
textAreaSplitter.Dispose();
secondaryTextArea = null;
textAreaSplitter = null;
}
if (primaryTextArea != null) {
primaryTextArea.Dispose();
}
textAreaPanel.Dispose();
textAreaPanel = null;
}
}
base.Dispose(disposing);
}
#region Update Methods
public override void EndUpdate()

2
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextEditorControlBase.cs

@ -724,6 +724,8 @@ namespace ICSharpCode.TextEditor @@ -724,6 +724,8 @@ namespace ICSharpCode.TextEditor
{
if (disposing) {
HighlightingManager.Manager.ReloadSyntaxHighlighting -= new EventHandler(ReloadHighlighting);
document.HighlightingStrategy = null;
document.UndoStack.TextEditorControl = null;
}
base.Dispose(disposing);
}

8
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs

@ -29,7 +29,7 @@ namespace ICSharpCode.TextEditor @@ -29,7 +29,7 @@ namespace ICSharpCode.TextEditor
/// <summary>
/// This class paints the textarea.
/// </summary>
public class TextView : AbstractMargin
public class TextView : AbstractMargin, IDisposable
{
int fontHeight;
//Hashtable charWitdh = new Hashtable();
@ -37,6 +37,12 @@ namespace ICSharpCode.TextEditor @@ -37,6 +37,12 @@ namespace ICSharpCode.TextEditor
Highlight highlight;
int physicalColumn = 0; // used for calculating physical column during paint
public void Dispose()
{
measureCache.Clear();
measureStringFormat.Dispose();
}
public Highlight Highlight {
get {
return highlight;

1
src/Main/Base/Project/Src/Gui/AbstractBaseViewContent.cs

@ -53,6 +53,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -53,6 +53,7 @@ namespace ICSharpCode.SharpDevelop.Gui
public virtual void Dispose()
{
workbenchWindow = null;
}
protected virtual void OnWorkbenchWindowChanged(EventArgs e)

1
src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs

@ -542,6 +542,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -542,6 +542,7 @@ namespace ICSharpCode.SharpDevelop.Gui
public void CloseWindowEvent(object sender, EventArgs e)
{
SdiWorkspaceWindow f = (SdiWorkspaceWindow)sender;
f.CloseEvent -= CloseWindowEvent;
if (f.ViewContent != null) {
((IWorkbench)wbForm).CloseContent(f.ViewContent);
if (f == oldSelectedWindow) {

13
src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs

@ -95,9 +95,18 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -95,9 +95,18 @@ namespace ICSharpCode.SharpDevelop.Gui
Show();
}
protected override void Dispose(bool isDisposing)
protected override void Dispose(bool disposing)
{
base.Dispose(isDisposing);
base.Dispose(disposing);
if (disposing) {
if (content != null)
DetachContent();
if (this.TabPageContextMenu != null) {
this.TabPageContextMenu.Dispose();
this.TabPageContextMenu = null;
}
}
}
public SdiWorkspaceWindow(IViewContent content)

6
src/Main/Base/Project/Src/Project/AbstractProject.cs

@ -33,14 +33,14 @@ namespace ICSharpCode.SharpDevelop.Project @@ -33,14 +33,14 @@ namespace ICSharpCode.SharpDevelop.Project
protected string fileName;
protected string language;
static string GetConfigurationNameFromKey(string key)
public static string GetConfigurationNameFromKey(string key)
{
return key.Substring(0, key.IndexOf('|'));
}
static string GetPlatformNameFromKey(string key)
public static string GetPlatformNameFromKey(string key)
{
return key.Substring(key.LastIndexOf('|') + 1);
return key.Substring(key.IndexOf('|') + 1);
}
public string[] GetConfigurationNames()

2
src/Main/Base/Project/Src/TextEditor/Gui/Editor/QuickClassBrowserPanel.cs

@ -202,6 +202,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -202,6 +202,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
{
if (disposing) {
this.textAreaControl.ActiveTextAreaControl.Caret.PositionChanged -= new EventHandler(CaretPositionChanged);
this.membersComboBox.Dispose();
this.classComboBox.Dispose();
}
base.Dispose(disposing);
}

10
src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs

@ -50,7 +50,6 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -50,7 +50,6 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
Document.BookmarkManager.Removed += new BookmarkEventHandler(BookmarkRemoved);
GenerateEditActions();
TextAreaDragDropHandler dragDropHandler = new TextAreaDragDropHandler();
TextEditorProperties = new SharpDevelopTextEditorProperties();
}
@ -90,7 +89,14 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -90,7 +89,14 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
{
base.Dispose(disposing);
if (disposing) {
errorDrawer.Dispose();
if (errorDrawer != null) {
errorDrawer.Dispose();
errorDrawer = null;
}
if (quickClassBrowserPanel != null) {
quickClassBrowserPanel.Dispose();
quickClassBrowserPanel = null;
}
CloseCodeCompletionWindow(this, EventArgs.Empty);
CloseInsightWindow(this, EventArgs.Empty);
}

18
src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs

@ -89,8 +89,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -89,8 +89,8 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
}
// KSL Start, New lines
FileSystemWatcher watcher;
bool wasChangedExternally = false;
protected FileSystemWatcher watcher;
protected bool wasChangedExternally = false;
// KSL End
public bool EnableUndo {
@ -223,7 +223,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -223,7 +223,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
}
}
void SetWatcher()
protected void SetWatcher()
{
try {
if (this.watcher == null) {
@ -237,10 +237,13 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -237,10 +237,13 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
this.watcher.NotifyFilter = NotifyFilters.LastWrite;
this.watcher.EnableRaisingEvents = true;
} catch (Exception) {
if (watcher != null) {
watcher.Dispose();
}
watcher = null;
}
}
void GotFocusEvent(object sender, EventArgs e)
protected virtual void GotFocusEvent(object sender, EventArgs e)
{
if (wasChangedExternally) {
wasChangedExternally = false;
@ -288,12 +291,15 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -288,12 +291,15 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
public override void Dispose()
{
base.Dispose();
((Form)ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.Workbench).Activated -= new EventHandler(GotFocusEvent);
if (WorkbenchSingleton.MainForm != null) {
WorkbenchSingleton.MainForm.Activated -= new EventHandler(GotFocusEvent);
}
if (this.watcher != null) {
this.watcher.Dispose();
this.watcher = null;
}
textAreaControl.Dispose();
base.Dispose();
}
public override bool IsReadOnly {

Loading…
Cancel
Save