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. 44
      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 @@ -300,16 +300,18 @@ namespace ICSharpCode.Core
CompoundClass compound = GetClassInternal(fullyQualifiedName, addClass.TypeParameters.Count, language) as CompoundClass;
if (compound != null) {
// possibly replace existing class (look for CU with same filename)
for (int i = 0; i < compound.Parts.Count; i++) {
if (compound.Parts[i].CompilationUnit.FileName == addClass.CompilationUnit.FileName) {
compound.Parts[i] = addClass;
compound.UpdateInformationFromParts();
LoggingService.Debug("Replaced old part!");
return;
lock (compound) {
for (int i = 0; i < compound.Parts.Count; i++) {
if (compound.Parts[i].CompilationUnit.FileName == addClass.CompilationUnit.FileName) {
compound.Parts[i] = addClass;
compound.UpdateInformationFromParts();
LoggingService.Debug("Replaced old part!");
return;
}
}
compound.Parts.Add(addClass);
compound.UpdateInformationFromParts();
}
compound.Parts.Add(addClass);
compound.UpdateInformationFromParts();
LoggingService.Debug("Added new part!");
return;
} else {
@ -460,12 +462,14 @@ namespace ICSharpCode.Core @@ -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
CompoundClass compound = GetClassInternal(fullyQualifiedName, @class.TypeParameters.Count, language) as CompoundClass;
if (compound == null) return;
compound.Parts.Remove(@class);
if (compound.Parts.Count > 0) {
compound.UpdateInformationFromParts();
return;
} else {
@class = compound; // all parts removed, remove compound class
lock (compound) {
compound.Parts.Remove(@class);
if (compound.Parts.Count > 0) {
compound.UpdateInformationFromParts();
return;
} else {
@class = compound; // all parts removed, remove compound class
}
}
}

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

@ -345,32 +345,34 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor @@ -345,32 +345,34 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor
}
}
int lastIndex = 0;
IComparer comparer = new Comparer(System.Globalization.CultureInfo.InvariantCulture);
lock (c) {
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));
}
items.Sort(lastIndex, c.Methods.Count, comparer);
lastIndex = items.Count;
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;
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;
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;
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;
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;
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.Items.Clear();

Loading…
Cancel
Save