From d8536c20b0b0c83fc97271c2f379d552a38eb500 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Sun, 23 Mar 2014 18:14:46 +0800 Subject: [PATCH] Fix added websearch twice issue. --- Wox.Infrastructure/Storage/BaseStorage.cs | 7 ++++++ .../UserSettings/UserSettingStorage.cs | 24 +++++++++---------- Wox/MainWindow.xaml.cs | 2 -- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Wox.Infrastructure/Storage/BaseStorage.cs b/Wox.Infrastructure/Storage/BaseStorage.cs index 01363cf1a..0e64144ca 100644 --- a/Wox.Infrastructure/Storage/BaseStorage.cs +++ b/Wox.Infrastructure/Storage/BaseStorage.cs @@ -36,6 +36,8 @@ namespace Wox.Infrastructure.Storage } } + protected virtual void LoadDefaultConfig() { } + private void Load() { string configPath = Path.Combine(configFolder, ConfigName + fileSuffix); @@ -55,8 +57,13 @@ namespace Wox.Infrastructure.Storage catch (Exception) { //no-op + LoadDefaultConfig(); } } + else + { + LoadDefaultConfig(); + } } public void Save() diff --git a/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs b/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs index 5956855b9..673406896 100644 --- a/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs +++ b/Wox.Infrastructure/Storage/UserSettings/UserSettingStorage.cs @@ -39,18 +39,6 @@ namespace Wox.Infrastructure.Storage.UserSettings [JsonProperty] public bool EnablePythonPlugins { get; set; } - public UserSettingStorage() - { - EnablePythonPlugins = true; - Theme = "Dark"; - ReplaceWinR = true; - WebSearches = LoadDefaultWebSearches(); - ProgramSources = LoadDefaultProgramSources(); - Hotkey = "Alt + Space"; - QueryBoxFont = FontFamily.GenericSansSerif.Name; - ResultItemFont = FontFamily.GenericSansSerif.Name; - } - public List LoadDefaultWebSearches() { List webSearches = new List(); @@ -107,5 +95,17 @@ namespace Wox.Infrastructure.Storage.UserSettings { get { return "config"; } } + + protected override void LoadDefaultConfig() + { + EnablePythonPlugins = true; + Theme = "Dark"; + ReplaceWinR = true; + WebSearches = LoadDefaultWebSearches(); + ProgramSources = LoadDefaultProgramSources(); + Hotkey = "Alt + Space"; + QueryBoxFont = FontFamily.GenericSansSerif.Name; + ResultItemFont = FontFamily.GenericSansSerif.Name; + } } } diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index dcdedb9ff..5e83f84d5 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -93,8 +93,6 @@ namespace Wox //DwmDropShadow.DropShadowToWindow(this); WindowIntelopHelper.DisableControlBox(this); - - throw new Exception(); } private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)