Skip to content

Commit

Permalink
Make sure the background parser gets disposed
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Feb 8, 2013
1 parent a3ed0f5 commit f212fea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Diff/DiffMargin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class DiffMargin : IWpfTextViewMargin

private readonly IWpfTextView _textView;
private readonly IEditorFormatMap _editorFormatMap;
private readonly DiffMarginViewModel _viewModel;
private readonly DiffMarginControl _gitDiffBarControl;
private bool _isDisposed;

Expand All @@ -44,7 +45,8 @@ public DiffMargin(IWpfTextView textView, ITextDocumentFactoryService textDocumen
_textView.Options.OptionChanged += HandleOptionChanged;

_gitDiffBarControl = new DiffMarginControl();
_gitDiffBarControl.DataContext = new DiffMarginViewModel(this, _textView, textDocumentFactoryService, new GitCommands());
_viewModel = new DiffMarginViewModel(this, _textView, textDocumentFactoryService, new GitCommands());
_gitDiffBarControl.DataContext = _viewModel;
_gitDiffBarControl.Width = MarginWidth;
UpdateVisibility();
}
Expand Down Expand Up @@ -117,6 +119,7 @@ public ITextViewMargin GetTextViewMargin(string marginName)
public void Dispose()
{
GC.SuppressFinalize(this);
_viewModel.Cleanup();
_isDisposed = true;
}

Expand Down
6 changes: 6 additions & 0 deletions Diff/ViewModel/DiffMarginViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public RelayCommand<DiffViewModel> NextChangeCommand
}
}

public override void Cleanup()
{
_parser.Dispose();
base.Cleanup();
}

private bool PreviousChangeCanExecute(DiffViewModel currentDiffViewModel)
{
return DiffViewModels.IndexOf(currentDiffViewModel) > 0;
Expand Down

0 comments on commit f212fea

Please sign in to comment.