Browse Source

Fixed exception when QuickClassBrowserPanel panel was refreshing while a partial class was updated by the parser thread.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1143 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
1a17634102
  1. 32
      src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs
  2. 52
      src/Main/Base/Project/Src/TextEditor/Gui/Editor/QuickClassBrowserPanel.cs

32
src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs

@ -300,16 +300,18 @@ namespace ICSharpCode.Core
CompoundClass compound = GetClassInternal(fullyQualifiedName, addClass.TypeParameters.Count, language) as CompoundClass; CompoundClass compound = GetClassInternal(fullyQualifiedName, addClass.TypeParameters.Count, language) as CompoundClass;
if (compound != null) { if (compound != null) {
// possibly replace existing class (look for CU with same filename) // possibly replace existing class (look for CU with same filename)
for (int i = 0; i < compound.Parts.Count; i++) { lock (compound) {
if (compound.Parts[i].CompilationUnit.FileName == addClass.CompilationUnit.FileName) { for (int i = 0; i < compound.Parts.Count; i++) {
compound.Parts[i] = addClass; if (compound.Parts[i].CompilationUnit.FileName == addClass.CompilationUnit.FileName) {
compound.UpdateInformationFromParts(); compound.Parts[i] = addClass;
LoggingService.Debug("Replaced old part!"); compound.UpdateInformationFromParts();
return; LoggingService.Debug("Replaced old part!");
return;
}
} }
compound.Parts.Add(addClass);
compound.UpdateInformationFromParts();
} }
compound.Parts.Add(addClass);
compound.UpdateInformationFromParts();
LoggingService.Debug("Added new part!"); LoggingService.Debug("Added new part!");
return; return;
} else { } else {
@ -460,12 +462,14 @@ namespace ICSharpCode.Core
// Use "as" cast to fix SD2-680: the stored class might be a part not marked as partial // Use "as" cast to fix SD2-680: the stored class might be a part not marked as partial
CompoundClass compound = GetClassInternal(fullyQualifiedName, @class.TypeParameters.Count, language) as CompoundClass; CompoundClass compound = GetClassInternal(fullyQualifiedName, @class.TypeParameters.Count, language) as CompoundClass;
if (compound == null) return; if (compound == null) return;
compound.Parts.Remove(@class); lock (compound) {
if (compound.Parts.Count > 0) { compound.Parts.Remove(@class);
compound.UpdateInformationFromParts(); if (compound.Parts.Count > 0) {
return; compound.UpdateInformationFromParts();
} else { return;
@class = compound; // all parts removed, remove compound class } else {
@class = compound; // all parts removed, remove compound class
}
} }
} }

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

@ -345,32 +345,34 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
} }
} }
int lastIndex = 0; lock (c) {
IComparer comparer = new Comparer(System.Globalization.CultureInfo.InvariantCulture); int lastIndex = 0;
IComparer comparer = new Comparer(System.Globalization.CultureInfo.InvariantCulture);
foreach (IMethod m in c.Methods) {
items.Add(new ComboBoxItem(m, m.Name, ClassBrowserIconService.GetIcon(m), partialMode ? currentPart.Methods.Contains(m) : true)); foreach (IMethod m in c.Methods) {
} items.Add(new ComboBoxItem(m, m.Name, ClassBrowserIconService.GetIcon(m), partialMode ? currentPart.Methods.Contains(m) : true));
items.Sort(lastIndex, c.Methods.Count, comparer); }
lastIndex = items.Count; items.Sort(lastIndex, c.Methods.Count, comparer);
lastIndex = items.Count;
foreach (IProperty p in c.Properties) {
items.Add(new ComboBoxItem(p, p.Name, ClassBrowserIconService.GetIcon(p), partialMode ? currentPart.Properties.Contains(p) : true)); foreach (IProperty p in c.Properties) {
} items.Add(new ComboBoxItem(p, p.Name, ClassBrowserIconService.GetIcon(p), partialMode ? currentPart.Properties.Contains(p) : true));
items.Sort(lastIndex, c.Properties.Count, comparer); }
lastIndex = items.Count; items.Sort(lastIndex, c.Properties.Count, comparer);
lastIndex = items.Count;
foreach (IField f in c.Fields) {
items.Add(new ComboBoxItem(f, f.Name, ClassBrowserIconService.GetIcon(f), partialMode ? currentPart.Fields.Contains(f) : true)); foreach (IField f in c.Fields) {
} items.Add(new ComboBoxItem(f, f.Name, ClassBrowserIconService.GetIcon(f), partialMode ? currentPart.Fields.Contains(f) : true));
items.Sort(lastIndex, c.Fields.Count, comparer); }
lastIndex = items.Count; items.Sort(lastIndex, c.Fields.Count, comparer);
lastIndex = items.Count;
foreach (IEvent evt in c.Events) {
items.Add(new ComboBoxItem(evt, evt.Name, ClassBrowserIconService.GetIcon(evt), partialMode ? currentPart.Events.Contains(evt) : true)); foreach (IEvent evt in c.Events) {
items.Add(new ComboBoxItem(evt, evt.Name, ClassBrowserIconService.GetIcon(evt), partialMode ? currentPart.Events.Contains(evt) : true));
}
items.Sort(lastIndex, c.Events.Count, comparer);
lastIndex = items.Count;
} }
items.Sort(lastIndex, c.Events.Count, comparer);
lastIndex = items.Count;
membersComboBox.BeginUpdate(); membersComboBox.BeginUpdate();
membersComboBox.Items.Clear(); membersComboBox.Items.Clear();

Loading…
Cancel
Save