Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hutchinson <mhutchinson@novell.com>2010-01-11 23:06:29 +0300
committerMichael Hutchinson <mhutchinson@novell.com>2010-01-11 23:06:29 +0300
commit7547b6d6ea4e7c8bad96df42825488f5d453623f (patch)
tree57730258b225fc513d4a9432fac9d92d65f42998 /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks
parent6580c85490fac94ca9ece6f30ae2e96ee6cfcbf1 (diff)
* MonoDevelop.Ide.Tasks/CommentTasksView.cs: Fix memory leak where
the comments task list could hold onto references to projects after they were closed. Also handle loading all comment tasks for the open workspaces if the view is first shown after loading. svn path=/trunk/monodevelop/; revision=149323
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/CommentTasksView.cs63
1 files changed, 44 insertions, 19 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/CommentTasksView.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/CommentTasksView.cs
index 666287d893..a4c06cbd66 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/CommentTasksView.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Tasks/CommentTasksView.cs
@@ -68,6 +68,7 @@ namespace MonoDevelop.Ide.Tasks
TaskStore comments = new TaskStore ();
Dictionary<string, TaskPriority> priorities = new Dictionary<string, TaskPriority> ();
+ HashSet<Solution> loadedSlns = new HashSet<Solution> ();
public CommentTasksView ()
{
@@ -128,16 +129,25 @@ namespace MonoDevelop.Ide.Tasks
col.Clicked += new EventHandler (Resort);
LoadColumnsVisibility ();
+
+ comments.BeginTaskUpdates ();
+ try {
+ foreach (var item in IdeApp.Workspace.Items) {
+ LoadWorkspaceItemContents (item);
+ }
+ } finally {
+ comments.EndTaskUpdates ();
+ }
comments.TasksAdded += (TaskEventHandler) DispatchService.GuiDispatch (new TaskEventHandler (GeneratedTaskAdded));
comments.TasksRemoved += (TaskEventHandler) DispatchService.GuiDispatch (new TaskEventHandler (GeneratedTaskRemoved));
PropertyService.PropertyChanged += (EventHandler<PropertyChangedEventArgs>) DispatchService.GuiDispatch (new EventHandler<PropertyChangedEventArgs> (OnPropertyUpdated));
-
+
CreateMenu ();
// Initialize with existing tags.
- foreach (Task t in comments)
+ foreach (Task t in comments)
AddGeneratedTask (t);
}
@@ -170,35 +180,50 @@ namespace MonoDevelop.Ide.Tasks
{
comments.BeginTaskUpdates ();
try {
- Solution sol = e.Item as Solution;
- if (sol != null) {
- // Load all tags that are stored in pidb files
- foreach (Project p in sol.GetAllProjects ()) {
- ProjectDom pContext = ProjectDomService.GetProjectDom (p);
- if (pContext == null)
- continue;
- foreach (ProjectFile file in p.Files) {
- IList<Tag> tags = pContext.GetSpecialComments (file.Name);
- if (tags !=null)
- UpdateCommentTags (sol, file.Name, tags);
- }
- }
- }
+ LoadWorkspaceItemContents (e.Item);
}
finally {
comments.EndTaskUpdates ();
}
}
+ void LoadWorkspaceItemContents (WorkspaceItem wob)
+ {
+ foreach (var sln in wob.GetAllSolutions ())
+ LoadSolutionContents (sln);
+ }
+
+ void LoadSolutionContents (Solution sln)
+ {
+ loadedSlns.Add (sln);
+
+ // Load all tags that are stored in pidb files
+ foreach (Project p in sln.GetAllProjects ()) {
+ ProjectDom pContext = ProjectDomService.GetProjectDom (p);
+ if (pContext == null)
+ continue;
+ foreach (ProjectFile file in p.Files) {
+ IList<Tag> tags = pContext.GetSpecialComments (file.Name);
+ if (tags != null && tags.Count > 0)
+ UpdateCommentTags (sln, file.Name, tags);
+ }
+ }
+ }
+
void OnWorkspaceItemUnloaded (object sender, WorkspaceItemEventArgs e)
{
+ foreach (var sln in e.Item.GetAllSolutions ())
+ loadedSlns.Remove (sln);
comments.RemoveItemTasks (e.Item, true);
}
void OnCommentTasksChanged (object sender, CommentTasksChangedEventArgs e)
{
- if (e.Project != null)
- UpdateCommentTags (e.Project, e.FileName, e.TagComments);
+ //because of parse queueing, it's possible for this event to come in after the solution is closed
+ //so we track which solutions are currently open so that we don't leak memory by holding
+ // on to references to closed projects
+ if (e.Project != null && e.Project.ParentSolution != null && loadedSlns.Contains (e.Project.ParentSolution))
+ UpdateCommentTags (e.Project.ParentSolution, e.FileName, e.TagComments);
}
void OnCommentTagsChanged (object sender, EventArgs e)
@@ -206,7 +231,7 @@ namespace MonoDevelop.Ide.Tasks
ReloadPriorities ();
}
- void UpdateCommentTags (IWorkspaceObject wob, FilePath fileName, IEnumerable<Tag> tagComments)
+ void UpdateCommentTags (Solution wob, FilePath fileName, IEnumerable<Tag> tagComments)
{
if (fileName == FilePath.Null)
return;