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

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

@ -412,10 +412,21 @@ namespace ICSharpCode.FormsDesigner.Services
public void RemoveCreator(string format) public void RemoveCreator(string format)
{ {
RemoveCreator(format, null);
} }
public void RemoveCreator(string format, IDesignerHost host) 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) public void RemoveToolboxItem(ToolboxItem toolboxItem)

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

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

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

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

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

@ -132,6 +132,15 @@ namespace ICSharpCode.TextEditor
textArea.LostFocus += new EventHandler(LostFocus); 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) public Point ValidatePosition(Point pos)
{ {
int line = Math.Max(0, Math.Min(textArea.Document.TotalNumberOfLines - 1, pos.Y)); int line = Math.Max(0, Math.Min(textArea.Document.TotalNumberOfLines - 1, pos.Y));
@ -259,12 +268,6 @@ namespace ICSharpCode.TextEditor
} }
} }
public void Dispose()
{
// DestroyCaret();
// caretCreated = false;
}
#region Native caret functions #region Native caret functions
[DllImport("User32.dll")] [DllImport("User32.dll")]
static extern bool CreateCaret(IntPtr hWnd, int hBitmap, int nWidth, int nHeight); 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
/// <summary> /// <summary>
/// This class views the line numbers and folding markers. /// This class views the line numbers and folding markers.
/// </summary> /// </summary>
public class GutterMargin : AbstractMargin public class GutterMargin : AbstractMargin, IDisposable
{ {
StringFormat numberStringFormat = (StringFormat)StringFormat.GenericTypographic.Clone(); StringFormat numberStringFormat = (StringFormat)StringFormat.GenericTypographic.Clone();
@ -34,6 +34,10 @@ namespace ICSharpCode.TextEditor
cursorStream.Close(); cursorStream.Close();
} }
public void Dispose()
{
numberStringFormat.Dispose();
}
public override Cursor Cursor { public override Cursor Cursor {
get { get {
@ -59,7 +63,7 @@ namespace ICSharpCode.TextEditor
{ {
numberStringFormat.LineAlignment = StringAlignment.Far; numberStringFormat.LineAlignment = StringAlignment.Far;
numberStringFormat.FormatFlags = StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.FitBlackBox | numberStringFormat.FormatFlags = StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.FitBlackBox |
StringFormatFlags.NoWrap | StringFormatFlags.NoClip; StringFormatFlags.NoWrap | StringFormatFlags.NoClip;
} }
public override void Paint(Graphics g, Rectangle rect) public override void Paint(Graphics g, Rectangle rect)
@ -151,7 +155,7 @@ namespace ICSharpCode.TextEditor
} }
} }
} }
textArea.Caret.Position = realmousepos; textArea.Caret.Position = realmousepos;
} }
} else { } else {

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

@ -614,9 +614,10 @@ namespace ICSharpCode.TextEditor
motherTextEditorControl.EndUpdate(); motherTextEditorControl.EndUpdate();
} }
public bool EnableCutOrPaste public bool EnableCutOrPaste {
{
get { get {
if (motherTextAreaControl == null)
return false;
if (TextEditorProperties.UseCustomLine == true) { if (TextEditorProperties.UseCustomLine == true) {
if (SelectionManager.HasSomethingSelected == true) { if (SelectionManager.HasSomethingSelected == true) {
if (Document.CustomLineManager.IsReadOnly(SelectionManager.SelectionCollection[0], false)) if (Document.CustomLineManager.IsReadOnly(SelectionManager.SelectionCollection[0], false))
@ -759,10 +760,22 @@ namespace ICSharpCode.TextEditor
if (disposing) { if (disposing) {
if (!disposed) { if (!disposed) {
disposed = true; 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.TextContentChanged -= new EventHandler(TextContentChanged);
Document.FoldingManager.FoldingsChanged -= new EventHandler(DocumentFoldingsChanged); 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
public bool EnableCut { public bool EnableCut {
get { get {
return true; //textArea.SelectionManager.HasSomethingSelected; return textArea.EnableCutOrPaste; //textArea.SelectionManager.HasSomethingSelected;
} }
} }
@ -54,7 +54,7 @@ namespace ICSharpCode.TextEditor
public bool EnableDelete { public bool EnableDelete {
get { 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
[Browsable(false)] [Browsable(false)]
public IDocument Document { public IDocument Document {
get { get {
return motherTextEditorControl.Document; if (motherTextEditorControl != null)
return motherTextEditorControl.Document;
return null;
} }
} }
public ITextEditorProperties TextEditorProperties { public ITextEditorProperties TextEditorProperties {
get { get {
return motherTextEditorControl.TextEditorProperties; if (motherTextEditorControl != null)
return motherTextEditorControl.TextEditorProperties;
return null;
} }
} }
@ -117,6 +121,19 @@ namespace ICSharpCode.TextEditor
if (!disposed) { if (!disposed) {
disposed = true; disposed = true;
Document.DocumentChanged -= new DocumentEventHandler(AdjustScrollBars); 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); base.Dispose(disposing);
@ -133,11 +150,11 @@ namespace ICSharpCode.TextEditor
int y = 0; int y = 0;
int h = 0; int h = 0;
if (hRuler != null) { if (hRuler != null) {
hRuler.Bounds = new Rectangle(0, hRuler.Bounds = new Rectangle(0,
0, 0,
Width - SystemInformation.HorizontalScrollBarArrowWidth, Width - SystemInformation.HorizontalScrollBarArrowWidth,
textArea.TextView.FontHeight); textArea.TextView.FontHeight);
y = hRuler.Bounds.Bottom; y = hRuler.Bounds.Bottom;
h = hRuler.Bounds.Height; h = hRuler.Bounds.Height;
} }
@ -151,9 +168,9 @@ namespace ICSharpCode.TextEditor
public void SetScrollBarBounds() public void SetScrollBarBounds()
{ {
vScrollBar.Bounds = new Rectangle(textArea.Bounds.Right, 0, SystemInformation.HorizontalScrollBarArrowWidth, Height - SystemInformation.VerticalScrollBarArrowHeight); 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, textArea.Bounds.Bottom,
Width - SystemInformation.HorizontalScrollBarArrowWidth, Width - SystemInformation.HorizontalScrollBarArrowWidth,
SystemInformation.VerticalScrollBarArrowHeight); SystemInformation.VerticalScrollBarArrowHeight);
} }
public void AdjustScrollBars(object sender, DocumentEventArgs e) public void AdjustScrollBars(object sender, DocumentEventArgs e)

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

@ -23,7 +23,7 @@ using System.Text;
using ICSharpCode.TextEditor.Document; using ICSharpCode.TextEditor.Document;
using ICSharpCode.TextEditor.Actions; using ICSharpCode.TextEditor.Actions;
namespace ICSharpCode.TextEditor namespace ICSharpCode.TextEditor
{ {
/// <summary> /// <summary>
@ -168,6 +168,32 @@ namespace ICSharpCode.TextEditor
Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(name); 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 #region Update Methods
public override void EndUpdate() public override void EndUpdate()

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

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

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

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

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

@ -53,6 +53,7 @@ namespace ICSharpCode.SharpDevelop.Gui
public virtual void Dispose() public virtual void Dispose()
{ {
workbenchWindow = null;
} }
protected virtual void OnWorkbenchWindowChanged(EventArgs e) 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
public void CloseWindowEvent(object sender, EventArgs e) public void CloseWindowEvent(object sender, EventArgs e)
{ {
SdiWorkspaceWindow f = (SdiWorkspaceWindow)sender; SdiWorkspaceWindow f = (SdiWorkspaceWindow)sender;
f.CloseEvent -= CloseWindowEvent;
if (f.ViewContent != null) { if (f.ViewContent != null) {
((IWorkbench)wbForm).CloseContent(f.ViewContent); ((IWorkbench)wbForm).CloseContent(f.ViewContent);
if (f == oldSelectedWindow) { if (f == oldSelectedWindow) {

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

@ -95,9 +95,18 @@ namespace ICSharpCode.SharpDevelop.Gui
Show(); 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) public SdiWorkspaceWindow(IViewContent content)

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

@ -33,14 +33,14 @@ namespace ICSharpCode.SharpDevelop.Project
protected string fileName; protected string fileName;
protected string language; protected string language;
static string GetConfigurationNameFromKey(string key) public static string GetConfigurationNameFromKey(string key)
{ {
return key.Substring(0, key.IndexOf('|')); 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() public string[] GetConfigurationNames()

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

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

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

@ -50,7 +50,6 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
Document.BookmarkManager.Removed += new BookmarkEventHandler(BookmarkRemoved); Document.BookmarkManager.Removed += new BookmarkEventHandler(BookmarkRemoved);
GenerateEditActions(); GenerateEditActions();
TextAreaDragDropHandler dragDropHandler = new TextAreaDragDropHandler();
TextEditorProperties = new SharpDevelopTextEditorProperties(); TextEditorProperties = new SharpDevelopTextEditorProperties();
} }
@ -90,7 +89,14 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
{ {
base.Dispose(disposing); base.Dispose(disposing);
if (disposing) { if (disposing) {
errorDrawer.Dispose(); if (errorDrawer != null) {
errorDrawer.Dispose();
errorDrawer = null;
}
if (quickClassBrowserPanel != null) {
quickClassBrowserPanel.Dispose();
quickClassBrowserPanel = null;
}
CloseCodeCompletionWindow(this, EventArgs.Empty); CloseCodeCompletionWindow(this, EventArgs.Empty);
CloseInsightWindow(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
} }
// KSL Start, New lines // KSL Start, New lines
FileSystemWatcher watcher; protected FileSystemWatcher watcher;
bool wasChangedExternally = false; protected bool wasChangedExternally = false;
// KSL End // KSL End
public bool EnableUndo { public bool EnableUndo {
@ -223,7 +223,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
} }
} }
void SetWatcher() protected void SetWatcher()
{ {
try { try {
if (this.watcher == null) { if (this.watcher == null) {
@ -237,10 +237,13 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
this.watcher.NotifyFilter = NotifyFilters.LastWrite; this.watcher.NotifyFilter = NotifyFilters.LastWrite;
this.watcher.EnableRaisingEvents = true; this.watcher.EnableRaisingEvents = true;
} catch (Exception) { } catch (Exception) {
if (watcher != null) {
watcher.Dispose();
}
watcher = null; watcher = null;
} }
} }
void GotFocusEvent(object sender, EventArgs e) protected virtual void GotFocusEvent(object sender, EventArgs e)
{ {
if (wasChangedExternally) { if (wasChangedExternally) {
wasChangedExternally = false; wasChangedExternally = false;
@ -288,12 +291,15 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
public override void Dispose() public override void Dispose()
{ {
base.Dispose(); if (WorkbenchSingleton.MainForm != null) {
((Form)ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.Workbench).Activated -= new EventHandler(GotFocusEvent); WorkbenchSingleton.MainForm.Activated -= new EventHandler(GotFocusEvent);
}
if (this.watcher != null) { if (this.watcher != null) {
this.watcher.Dispose(); this.watcher.Dispose();
this.watcher = null;
} }
textAreaControl.Dispose(); textAreaControl.Dispose();
base.Dispose();
} }
public override bool IsReadOnly { public override bool IsReadOnly {

Loading…
Cancel
Save