Skip to content

Commit

Permalink
Merge pull request #609 from Hosch250/BugFixBranch
Browse files Browse the repository at this point in the history
Close issue #596
  • Loading branch information
Hosch250 committed Jun 11, 2015
2 parents 6a041d8 + 616ef24 commit 0d967a7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
41 changes: 29 additions & 12 deletions RetailCoder.VBE/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public class App : IDisposable
{
private readonly VBE _vbe;
private readonly AddIn _addIn;
private readonly IList<IInspection> _inspections;
private readonly Inspector _inspector;
private readonly ParserErrorsPresenter _parserErrorsPresenter;
private IList<IInspection> _inspections;
private Inspector _inspector;
private ParserErrorsPresenter _parserErrorsPresenter;
private readonly IGeneralConfigService _configService = new ConfigurationLoader();
private readonly ActiveCodePaneEditor _editor;
private readonly IRubberduckParser _parser;
private IRubberduckParser _parser;

private Configuration _config;
private RubberduckMenu _menu;
Expand All @@ -35,18 +35,12 @@ public App(VBE vbe, AddIn addIn)
{
_vbe = vbe;
_addIn = addIn;
_inspections = _configService.GetImplementedCodeInspections();

_parser = new RubberduckParser();
_parserErrorsPresenter = new ParserErrorsPresenter(vbe, addIn);
_parser.ParseStarted += _parser_ParseStarted;
_parser.ParserError += _parser_ParserError;
_configService.SettingsChanged += _configService_SettingsChanged;

_editor = new ActiveCodePaneEditor(vbe);

_inspector = new Inspector(_parser, _inspections);

LoadConfig();
}

Expand All @@ -71,8 +65,6 @@ private void LoadConfig()
_configService.SaveConfiguration(_config);
}

EnableCodeInspections(_config);

if (_menu != null)
{
_menu.Dispose();
Expand All @@ -92,6 +84,31 @@ private void LoadConfig()
_codeInspectionsToolbar.Dispose();
}

if (_inspector != null)
{
_inspector.Dispose();
}

if (_parserErrorsPresenter != null)
{
_parserErrorsPresenter.Dispose();
}

if (_parser != null)
{
_parser.ParseStarted -= _parser_ParseStarted;
_parser.ParserError -= _parser_ParserError;
}
_parser = new RubberduckParser();
_parser.ParseStarted += _parser_ParseStarted;
_parser.ParserError += _parser_ParserError;

_inspections = _configService.GetImplementedCodeInspections();
_inspector = new Inspector(_parser, _inspections);
EnableCodeInspections(_config);

_parserErrorsPresenter = new ParserErrorsPresenter(_vbe, _addIn);

_menu = new RubberduckMenu(_vbe, _addIn, _configService, _parser, _editor, _inspector);
_menu.Initialize();

Expand Down
1 change: 0 additions & 1 deletion RetailCoder.VBE/UI/RubberduckMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ protected override void Dispose(bool disposing)
menuBarControls.Parent.FindControl(_menu.Type, _menu.Id, _menu.Tag, _menu.Visible).Delete();

_disposed = true;

base.Dispose(true);
}
}
Expand Down
6 changes: 4 additions & 2 deletions RetailCoder.VBE/UI/Settings/GeneralSettingsControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ namespace Rubberduck.UI.Settings
{
public partial class GeneralSettingsControl : UserControl
{
private IGeneralConfigService _configService;
private readonly IGeneralConfigService _configService;
private readonly DisplayLanguageSetting _currentLanguage;

public GeneralSettingsControl()
{
Expand Down Expand Up @@ -36,13 +37,14 @@ private void ResetSettings()
{
File.Delete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Rubberduck\\rubberduck.config"));
var config = _configService.GetDefaultConfiguration();
_configService.SaveConfiguration(config);
_configService.SaveConfiguration(config, !Equals(_currentLanguage, config.UserSettings.LanguageSetting));
}

public GeneralSettingsControl(DisplayLanguageSetting displayLanguage, IGeneralConfigService configService)
: this()
{
_configService = configService;
_currentLanguage = displayLanguage;
LanguageList.SelectedItem = displayLanguage;
}

Expand Down
4 changes: 3 additions & 1 deletion RetailCoder.VBE/UI/Settings/SettingsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@ private void ActivateControl(Control control)

private void SaveConfig()
{
var langChanged = !Equals(_config.UserSettings.LanguageSetting, _generalSettingsView.SelectedLanguage);

_config.UserSettings.LanguageSetting = _generalSettingsView.SelectedLanguage;
_config.UserSettings.ToDoListSettings.ToDoMarkers = _todoView.TodoMarkers.ToArray();
// The datagrid view of the CodeInspectionControl seems to keep the config magically in sync, so I don't manually do it here.
_configService.SaveConfiguration(_config);
_configService.SaveConfiguration(_config, langChanged);
}
}
}

0 comments on commit 0d967a7

Please sign in to comment.