From f14a5b92296f2d7cba3cf55cfb69c1e217725d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=98=E9=9F=AC=20=E5=BC=A0?= Date: Tue, 16 Feb 2021 15:54:11 +0800 Subject: [PATCH] add default win32, so we should not contain null --- .../Programs/Win32.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs index 8657f0ec0..aeb35ea39 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/Win32.cs @@ -35,6 +35,20 @@ namespace Flow.Launcher.Plugin.Program.Programs private const string ShortcutExtension = "lnk"; private const string ExeExtension = "exe"; + private static readonly Win32 Default = new Win32() + { + Name = string.Empty, + Description = string.Empty, + IcoPath = string.Empty, + FullPath = string.Empty, + LnkResolvedPath = null, + ParentDirectory = string.Empty, + ExecutableName = null, + UniqueIdentifier = string.Empty, + Valid = false, + Enabled = false + }; + public Result Result(string query, IPublicAPI api) { @@ -423,12 +437,12 @@ namespace Flow.Launcher.Plugin.Program.Programs private static Win32 GetProgramFromPath(string path) { if (string.IsNullOrEmpty(path)) - return null; + return Default; path = Environment.ExpandEnvironmentVariables(path); if (!File.Exists(path)) - return null; + return Default; var entry = Win32Program(path); @@ -504,7 +518,6 @@ namespace Flow.Launcher.Plugin.Program.Programs programs = programs.Concat(startMenu); } - return ProgramsHasher(programs.Where(p => p != null)); } #if DEBUG //This is to make developer aware of any unhandled exception and add in handling.