deal with CreateProcess failure

This commit is contained in:
Paddy Xu
2017-11-17 12:29:50 +02:00
parent 1980ed1590
commit 057126a7a0
2 changed files with 53 additions and 40 deletions

View File

@@ -136,9 +136,10 @@ namespace QuickLook.Plugin.ImageViewer.Exiv2
} }
private Dictionary<string, string> Run(string arg, string regexSplit) private Dictionary<string, string> Run(string arg, string regexSplit)
{
try
{ {
string result; string result;
using (var p = new Process()) using (var p = new Process())
{ {
p.StartInfo.UseShellExecute = false; p.StartInfo.UseShellExecute = false;
@@ -157,6 +158,11 @@ namespace QuickLook.Plugin.ImageViewer.Exiv2
? new Dictionary<string, string>() ? new Dictionary<string, string>()
: ParseResult(result, regexSplit); : ParseResult(result, regexSplit);
} }
catch (Exception)
{
return new Dictionary<string, string>();
}
}
private Dictionary<string, string> ParseResult(string result, string regexSplit) private Dictionary<string, string> ParseResult(string result, string regexSplit)
{ {

View File

@@ -39,6 +39,8 @@ namespace QuickLook.Plugin.VideoViewer.FFmpeg
} }
private bool Run(string media) private bool Run(string media)
{
try
{ {
string result; string result;
@@ -63,6 +65,11 @@ namespace QuickLook.Plugin.VideoViewer.FFmpeg
ParseResult(result); ParseResult(result);
return true; return true;
} }
catch (Exception)
{
return false;
}
}
private void ParseResult(string result) private void ParseResult(string result)
{ {
@@ -71,28 +78,28 @@ namespace QuickLook.Plugin.VideoViewer.FFmpeg
public bool CanDecode() public bool CanDecode()
{ {
var info = _infoNavigator.SelectSingleNode("/ffprobe/format[@probe_score>25]"); var info = _infoNavigator?.SelectSingleNode("/ffprobe/format[@probe_score>25]");
return info != null; return info != null;
} }
public string GetFormatName() public string GetFormatName()
{ {
var format = _infoNavigator.SelectSingleNode("/ffprobe/format/@format_name")?.Value; var format = _infoNavigator?.SelectSingleNode("/ffprobe/format/@format_name")?.Value;
return format ?? string.Empty; return format ?? string.Empty;
} }
public string GetFormatLongName() public string GetFormatLongName()
{ {
var format = _infoNavigator.SelectSingleNode("/ffprobe/format/@format_long_name")?.Value; var format = _infoNavigator?.SelectSingleNode("/ffprobe/format/@format_long_name")?.Value;
return format ?? string.Empty; return format ?? string.Empty;
} }
public bool HasAudio() public bool HasAudio()
{ {
var duration = _infoNavigator.SelectSingleNode("/ffprobe/streams/stream[@codec_type='audio'][1]/@duration") var duration = _infoNavigator?.SelectSingleNode("/ffprobe/streams/stream[@codec_type='audio'][1]/@duration")
?.Value; ?.Value;
if (duration == null) if (duration == null)
@@ -104,7 +111,7 @@ namespace QuickLook.Plugin.VideoViewer.FFmpeg
public bool HasVideo() public bool HasVideo()
{ {
var fps = _infoNavigator.SelectSingleNode("/ffprobe/streams/stream[@codec_type='video'][1]/@avg_frame_rate") var fps = _infoNavigator?.SelectSingleNode("/ffprobe/streams/stream[@codec_type='video'][1]/@avg_frame_rate")
?.Value; ?.Value;
if (fps == null) if (fps == null)
@@ -118,9 +125,9 @@ namespace QuickLook.Plugin.VideoViewer.FFmpeg
if (!HasVideo()) if (!HasVideo())
return Size.Empty; return Size.Empty;
var width = _infoNavigator.SelectSingleNode("/ffprobe/streams/stream[@codec_type='video'][1]/@coded_width") var width = _infoNavigator?.SelectSingleNode("/ffprobe/streams/stream[@codec_type='video'][1]/@coded_width")
?.Value; ?.Value;
var height = _infoNavigator.SelectSingleNode("/ffprobe/streams/stream[@codec_type='video'][1]/@coded_height") var height = _infoNavigator?.SelectSingleNode("/ffprobe/streams/stream[@codec_type='video'][1]/@coded_height")
?.Value; ?.Value;
if (width == null || height == null) if (width == null || height == null)