Browse Source

Fix some more crashes reported by UDC.

pull/39/merge
Daniel Grunwald 13 years ago
parent
commit
72d01bd043
  1. 2
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs
  2. 6
      src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs
  3. 32
      src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/DomPersistence.cs

2
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs

@ -386,6 +386,8 @@ namespace ICSharpCode.AvalonEdit.AddIn
void TextAreaCaretPositionChanged(object sender, EventArgs e) void TextAreaCaretPositionChanged(object sender, EventArgs e)
{ {
if (document == null)
return; // can happen if the editor is closed with Ctrl+F4 while selecting text
Debug.Assert(sender is Caret); Debug.Assert(sender is Caret);
Debug.Assert(!document.IsInUpdate); Debug.Assert(!document.IsInUpdate);
if (sender == this.ActiveTextEditor.TextArea.Caret) { if (sender == this.ActiveTextEditor.TextArea.Caret) {

6
src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs

@ -356,9 +356,9 @@ namespace ICSharpCode.SharpDevelop.Gui
void ComboBoxSelectedIndexChanged(object sender, EventArgs e) void ComboBoxSelectedIndexChanged(object sender, EventArgs e)
{ {
if (!inUpdate) { if (!inUpdate && host!=null) {
if (host!=null) { ISelectionService selectionService = (ISelectionService)host.GetService(typeof(ISelectionService));
ISelectionService selectionService = (ISelectionService)host.GetService(typeof(ISelectionService)); if (selectionService != null) {
if (comboBox.SelectedIndex >= 0) { if (comboBox.SelectedIndex >= 0) {
selectionService.SetSelectedComponents(new object[] { GetComboBoxItem(comboBox.SelectedIndex) }); selectionService.SetSelectedComponents(new object[] { GetComboBoxItem(comboBox.SelectedIndex) });
} else { } else {

32
src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ReflectionLayer/DomPersistence.cs

@ -38,20 +38,26 @@ namespace ICSharpCode.SharpDevelop.Dom
#region Cache management #region Cache management
public string SaveProjectContent(ReflectionProjectContent pc) public string SaveProjectContent(ReflectionProjectContent pc)
{ {
// create cache directory, if necessary try {
Directory.CreateDirectory(cacheDirectory); // create cache directory, if necessary
Directory.CreateDirectory(cacheDirectory);
string assemblyFullName = pc.AssemblyFullName;
int pos = assemblyFullName.IndexOf(','); string assemblyFullName = pc.AssemblyFullName;
string fileName = Path.Combine(cacheDirectory, int pos = assemblyFullName.IndexOf(',');
assemblyFullName.Substring(0, pos) string fileName = Path.Combine(cacheDirectory,
+ "." + pc.AssemblyLocation.GetHashCode().ToString("x", CultureInfo.InvariantCulture) assemblyFullName.Substring(0, pos)
+ ".dat"); + "." + pc.AssemblyLocation.GetHashCode().ToString("x", CultureInfo.InvariantCulture)
AddFileNameToCacheIndex(Path.GetFileName(fileName), pc); + ".dat");
using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) { AddFileNameToCacheIndex(Path.GetFileName(fileName), pc);
WriteProjectContent(pc, fs); using (FileStream fs = new FileStream(fileName, FileMode.Create, FileAccess.Write)) {
WriteProjectContent(pc, fs);
}
return fileName;
} catch (IOException) {
return null;
} catch (UnauthorizedAccessException) {
return null;
} }
return fileName;
} }
public ReflectionProjectContent LoadProjectContentByAssemblyName(string assemblyName) public ReflectionProjectContent LoadProjectContentByAssemblyName(string assemblyName)

Loading…
Cancel
Save