From 2e8f6fdd4de2c65f9d641d234c3e922fcb121afe Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Mon, 30 Mar 2009 20:12:23 +0000 Subject: [PATCH] fixed threading bug in QueryCompiler git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3941 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Controller/Queries/QueryCompiler.cs | 24 ++++++++++--------- .../Frontend/Controls/QueryView.xaml.cs | 3 ++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/AddIns/Misc/Profiler/Controller/Queries/QueryCompiler.cs b/src/AddIns/Misc/Profiler/Controller/Queries/QueryCompiler.cs index 239ed4e942..75fb79a8c4 100644 --- a/src/AddIns/Misc/Profiler/Controller/Queries/QueryCompiler.cs +++ b/src/AddIns/Misc/Profiler/Controller/Queries/QueryCompiler.cs @@ -76,17 +76,19 @@ namespace ICSharpCode.Profiler.Controller.Queries if (string.IsNullOrEmpty(this.currentQuery)) return false; - if (!queryCache.ContainsKey(this.currentQuery)) { - string code = text + PreprocessString(currentQuery) + textEnd; - CompilerResults results = csc.CompileAssemblyFromSource(GetParameters(), code); - report(results.Errors.Cast()); - - if (results.Errors.Count > 0) - return false; - - queryCache.Add(this.currentQuery, results.CompiledAssembly); - } else { - report(new List().AsEnumerable()); // clear errors list + lock (queryCache) { + if (!queryCache.ContainsKey(this.currentQuery)) { + string code = text + PreprocessString(currentQuery) + textEnd; + CompilerResults results = csc.CompileAssemblyFromSource(GetParameters(), code); + report(results.Errors.Cast()); + + if (results.Errors.Count > 0) + return false; + + queryCache.Add(this.currentQuery, results.CompiledAssembly); + } else { + report(new List().AsEnumerable()); // clear errors list + } } return true; diff --git a/src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml.cs b/src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml.cs index 61cd9a3942..9570520ac9 100644 --- a/src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml.cs +++ b/src/AddIns/Misc/Profiler/Frontend/Controls/QueryView.xaml.cs @@ -148,9 +148,10 @@ namespace ICSharpCode.Profiler.Controls layer.Add(ad); int rangeStart = RangeStart; int rangeEnd = RangeEnd; + string query = this.CurrentQuery; ProfilingDataProvider provider = Provider; - QueryCompiler compiler = new QueryCompiler(Reporter, this.CurrentQuery); + QueryCompiler compiler = new QueryCompiler(Reporter, query); ringDiagram.SelectedRoot = null; task.Execute(() => LoadWorker(provider, compiler, rangeStart, rangeEnd),