Browse Source

Fix NullReferenceException in SharpDevelopInsightWindow

pull/517/head
Daniel Grunwald 11 years ago
parent
commit
6c46af6b41
  1. 7
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeCompletionEditorAdapter.cs
  2. 13
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopInsightWindow.cs

7
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeCompletionEditorAdapter.cs

@ -78,7 +78,12 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -78,7 +78,12 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
public override IInsightWindow ActiveInsightWindow {
get { return textEditor.ActiveInsightWindow.activeAdapter; }
get {
if (textEditor.ActiveInsightWindow != null)
return textEditor.ActiveInsightWindow.activeAdapter;
else
return null;
}
}
public override ICompletionListWindow ActiveCompletionWindow {

13
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopInsightWindow.cs

@ -94,17 +94,24 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -94,17 +94,24 @@ namespace ICSharpCode.AvalonEdit.AddIn
void OnClosed(object sender, EventArgs e)
{
activeAdapter.OnClosed();
if (activeAdapter != null)
activeAdapter.OnClosed();
}
void caret_PositionChanged(object sender, EventArgs e)
{
activeAdapter.OnCaretPositionChanged(e);
// It is possible that the insight window is not initialized correctly
// due to an exception, and then caret_PositionChanged is called in a finally block
// during exception handling.
// Check for a null adapter to avoid a NullReferenceException that hides the first exception.
if (activeAdapter != null)
activeAdapter.OnCaretPositionChanged(e);
}
void document_Changed(object sender, DocumentChangeEventArgs e)
{
activeAdapter.OnDocumentChanged(e);
if (activeAdapter != null)
activeAdapter.OnDocumentChanged(e);
}
}

Loading…
Cancel
Save