From 4121bbc772c6404e74b2c3ba7749ea2a0f983f48 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Tue, 12 Aug 2014 12:21:04 +0800 Subject: [PATCH] Fix a programs bug if custom program folder is not exist. --- .../Program/IProgramSource.cs | 2 +- .../ProgramSources/FileSystemProgramSource.cs | 6 ++++-- Wox/Helper/Forker.cs | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Wox.Plugin.SystemPlugins/Program/IProgramSource.cs b/Wox.Plugin.SystemPlugins/Program/IProgramSource.cs index 44eb232e6f..f2443c46f7 100644 --- a/Wox.Plugin.SystemPlugins/Program/IProgramSource.cs +++ b/Wox.Plugin.SystemPlugins/Program/IProgramSource.cs @@ -32,7 +32,7 @@ namespace Wox.Plugin.SystemPlugins.Program switch (Path.GetExtension(file).ToLower()) { case ".exe": - p.ExecuteName = global::System.IO.Path.GetFileName(file); + p.ExecuteName = Path.GetFileName(file); try { FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(file); diff --git a/Wox.Plugin.SystemPlugins/Program/ProgramSources/FileSystemProgramSource.cs b/Wox.Plugin.SystemPlugins/Program/ProgramSources/FileSystemProgramSource.cs index a1985a7ede..c913143607 100644 --- a/Wox.Plugin.SystemPlugins/Program/ProgramSources/FileSystemProgramSource.cs +++ b/Wox.Plugin.SystemPlugins/Program/ProgramSources/FileSystemProgramSource.cs @@ -30,8 +30,10 @@ namespace Wox.Plugin.SystemPlugins.Program.ProgramSources public override List LoadPrograms() { List list = new List(); - GetAppFromDirectory(BaseDirectory, list); - + if (Directory.Exists(BaseDirectory)) + { + GetAppFromDirectory(BaseDirectory, list); + } return list; } diff --git a/Wox/Helper/Forker.cs b/Wox/Helper/Forker.cs index ab7b284715..658e2e5b86 100644 --- a/Wox/Helper/Forker.cs +++ b/Wox/Helper/Forker.cs @@ -105,8 +105,19 @@ namespace Wox.Helper ThreadPool.QueueUserWorkItem(delegate { Exception exception = null; - try { action(); } - catch (Exception ex) { exception = ex; } + try + { + action(); + } + catch (Exception ex) + { + exception = ex; +#if (DEBUG) + { + throw; + } +#endif + } OnItemComplete(state, exception); }); return this;