From 2a8e2475d81fe6d91e2dab6bfef6f7e1f10b10ef Mon Sep 17 00:00:00 2001 From: RKrom Date: Wed, 1 May 2013 17:02:40 +0000 Subject: [PATCH] Fix for stability issues with the ExternalCommandPlugin. git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2602 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- .../ExternalCommandPlugin.cs | 10 +++++++--- GreenshotPlugin/Core/PluginUtils.cs | 12 ++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs b/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs index e122bdb77..0a67ab8b2 100644 --- a/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs +++ b/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs @@ -122,9 +122,13 @@ namespace ExternalCommand { itemPlugInRoot = new ToolStripMenuItem(); itemPlugInRoot.Text = Language.GetString("externalcommand", "contextmenu_configure"); itemPlugInRoot.Tag = host; - string exePath = PluginUtils.GetExePath("cmd.exe"); - if (exePath != null && File.Exists(exePath)) { - itemPlugInRoot.Image = PluginUtils.GetExeIcon(exePath, 0); + try { + string exePath = PluginUtils.GetExePath("cmd.exe"); + if (exePath != null && File.Exists(exePath)) { + itemPlugInRoot.Image = PluginUtils.GetExeIcon(exePath, 0); + } + } catch (Exception ex) { + LOG.Warn("Couldn't get the cmd.exe image", ex); } itemPlugInRoot.Click += new System.EventHandler(ConfigMenuClick); diff --git a/GreenshotPlugin/Core/PluginUtils.cs b/GreenshotPlugin/Core/PluginUtils.cs index aa970856d..fbe8d8e7e 100644 --- a/GreenshotPlugin/Core/PluginUtils.cs +++ b/GreenshotPlugin/Core/PluginUtils.cs @@ -53,10 +53,14 @@ namespace GreenshotPlugin.Core { return (string)key.GetValue(""); } } - foreach (string test in (Environment.GetEnvironmentVariable("PATH") ?? "").Split(';')) { - string path = test.Trim(); - if (!String.IsNullOrEmpty(path) && File.Exists(path = Path.Combine(path, exeName))) { - return Path.GetFullPath(path); + foreach (string pathEntry in (Environment.GetEnvironmentVariable("PATH") ?? "").Split(';')) { + try { + string path = pathEntry.Trim(); + if (!String.IsNullOrEmpty(path) && File.Exists(path = Path.Combine(path, exeName))) { + return Path.GetFullPath(path); + } + } catch (Exception) { + LOG.WarnFormat("Problem with path entry '{0}'.", pathEntry); } } return null;