From 0a900bc5d2b46f4d039ef76d6b8beab5b324809d Mon Sep 17 00:00:00 2001 From: RKrom Date: Fri, 12 Apr 2013 13:27:17 +0000 Subject: [PATCH] Stability fix for #1497 git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2562 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- GreenshotExternalCommandPlugin/IconCache.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/GreenshotExternalCommandPlugin/IconCache.cs b/GreenshotExternalCommandPlugin/IconCache.cs index fc608c28d..fab1b4c5d 100644 --- a/GreenshotExternalCommandPlugin/IconCache.cs +++ b/GreenshotExternalCommandPlugin/IconCache.cs @@ -15,19 +15,21 @@ namespace ExternalCommand { if (commandName != null) { if (!iconCache.ContainsKey(commandName)) { Image icon = null; - if (File.Exists(config.commandlines[commandName])) { + if (config.commandlines.ContainsKey(commandName) && File.Exists(config.commandlines[commandName])) { try { icon = PluginUtils.GetExeIcon(config.commandlines[commandName], 0); } catch (Exception ex) { LOG.Warn("Problem loading icon for " + config.commandlines[commandName], ex); } } + // Also add null to the cache if nothing is found iconCache.Add(commandName, icon); } - return iconCache[commandName]; - } else { - return null; + if (iconCache.ContainsKey(commandName)) { + return iconCache[commandName]; + } } + return null; } } }