[mono/monodevelop] 62fe0a09: Fixed 'Bug 16268 - Type system exceptions in the log'.

Mike Krüger ([email protected]) <[email protected]> Sat, 16 Nov 2013 06:07:56 +0000
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <000001425f85d81b-02a7a9d9-f3d3-4029-b975-737976c7aa10-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/monodevelop
  Compare: https://github.com/mono/monodevelop/compare/5bbcc0351da1...62fe0a09ff1b

   Commit: 62fe0a09ff1b82bf3d5d70c1e59e8e3cb16b3177
   Author: Mike Krüger <[email protected]> (mkrueger)
     Date: 2013-11-16 06:06:45 GMT
      URL: https://github.com/mono/monodevelop/commit/62fe0a09ff1b82bf3d5d70c1e59e8e3cb16b3177

Fixed 'Bug 16268 - Type system exceptions in the log'.

Changed paths:
  M main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs

Modified: main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/TypeSystemService.cs
===================================================================
@@ -1128,19 +1128,25 @@ public void InformFileAdded (ParsedFileEventArgs e)
 
 			[NonSerialized]
 			int loadOperationDepth = 0;
+			[NonSerialized]
+			readonly object loadOperationLocker = new object ();
 
-			internal int LoadOperationDepth {
-				get {
-					return loadOperationDepth;
-				}
-				set {
-					loadOperationDepth = value;
-					if (loadOperationDepth < 0)
-						throw new InvalidOperationException ();
-					OnLoad (EventArgs.Empty);
+			internal void BeginLoadOperation ()
+			{
+				lock (loadOperationLocker) {
+					loadOperationDepth++;
 				}
 			}
 
+			internal void EndLoadOperation ()
+			{
+				lock (loadOperationLocker) {
+					if (loadOperationDepth > 0) {
+						loadOperationDepth--;
+					}
+				}
+				OnLoad (EventArgs.Empty);
+			}
 			bool inLoad;
 			public bool InLoad {
 				get {
@@ -1269,7 +1275,7 @@ public LazyProjectLoader (ProjectContentWrapper wrapper)
 					this.wrapper = wrapper;
 					contextTask = Task.Factory.StartNew (delegate {
 						try {
-							this.wrapper.LoadOperationDepth++;
+							this.wrapper.BeginLoadOperation ();
 							var p = this.wrapper.Project;
 							var context = LoadProjectCache (p);
 
@@ -1288,7 +1294,7 @@ public LazyProjectLoader (ProjectContentWrapper wrapper)
 							QueueParseJob (this.wrapper);
 							return context;
 						} finally {
-							this.wrapper.LoadOperationDepth--;
+							this.wrapper.EndLoadOperation ();
 						}
 					});
 				}
@@ -2537,7 +2543,7 @@ public void Run (IProgressMonitor monitor)
 				TypeSystemParser parser = null;
 				var tags = Context.GetExtensionObject <ProjectCommentTags> ();
 				try {
-					Context.LoadOperationDepth++;
+					Context.BeginLoadOperation ();
 					foreach (var file in (FileList ?? Context.Project.Files)) {
 						var fileName = file.FilePath;
 						if (filesSkippedInParseThread.Any (f => f == fileName))
@@ -2558,7 +2564,7 @@ public void Run (IProgressMonitor monitor)
 						Context.InformFileAdded (new ParsedFileEventArgs (parsedDocument.ParsedFile));
 					}
 				} finally {
-					Context.LoadOperationDepth--;
+					Context.EndLoadOperation ();
 				}
 			}
 		}
@@ -2614,7 +2620,7 @@ static void QueueParseJob (ProjectContentWrapper context, IEnumerable<ProjectFil
 			};
 			lock (parseQueueLock) {
 				RemoveParseJob (context);
-				context.LoadOperationDepth++;
+				context.BeginLoadOperation ();
 				parseQueueIndex [context] = job;
 				parseQueue.Enqueue (job);
 				parseEvent.Set ();
@@ -2652,7 +2658,7 @@ static void RemoveParseJob (ProjectContentWrapper project)
 				ParsingJob job;
 				if (parseQueueIndex.TryGetValue (project, out job)) {
 					parseQueueIndex.Remove (project);
-					project.LoadOperationDepth--;
+					project.EndLoadOperation ();
 				}
 			}
 		}
@@ -2705,7 +2711,7 @@ static void CheckModifiedFiles (Project project, ProjectFile[] projectFiles, Pro
 		{
 			content.RunWhenLoaded (delegate(IProjectContent cnt) {
 				try {
-					content.LoadOperationDepth++;
+					content.BeginLoadOperation ();
 					var modifiedFiles = new List<ProjectFile> ();
 					var oldFileNewFile = new List<Tuple<ProjectFile, IUnresolvedFile>> ();
 
@@ -2747,7 +2753,7 @@ static void CheckModifiedFiles (Project project, ProjectFile[] projectFiles, Pro
 				} catch (Exception e) {
 					LoggingService.LogError ("Exception in check modified files.", e);
 				} finally {
-					content.LoadOperationDepth--;
+					content.EndLoadOperation ();
 				}
 
 			});
@@ -2820,7 +2826,7 @@ static void ConsumeParsingQueue ()
 								monitor = GetParseProgressMonitor ();
 							monitor.ReportError (null, ex);
 						} finally {
-							job.Context.LoadOperationDepth--;
+							job.Context.EndLoadOperation ();
 						}
 					}
 					
_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches