From: sr55 Date: Sat, 16 Feb 2019 21:21:54 +0000 (+0000) Subject: WinGui: Attempt to fix the the exception handling when AccessViolations occur. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e6cd082d696cc37b8bbd8812486f5639016238a0;p=handbrake WinGui: Attempt to fix the the exception handling when AccessViolations occur. --- diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs index 9c499c9c5..77201bc38 100644 --- a/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs @@ -65,7 +65,11 @@ namespace HandBrake.Interop.Interop { try { - TryInit(); + bool passed = TryInit(); + if (!passed) + { + failedWithHardware = true; + } } catch (Exception e) { @@ -86,12 +90,25 @@ namespace HandBrake.Interop.Interop } [HandleProcessCorruptedStateExceptions] - static void TryInit() + static bool TryInit() { - if (HBFunctions.hb_global_init() == -1) + try { - throw new InvalidOperationException("HB global init failed."); + if (HBFunctions.hb_global_init() == -1) + { + throw new InvalidOperationException("HB global init failed."); + } } + catch (AccessViolationException e) + { + return false; + } + catch (Exception e) + { + return false; + } + + return true; } ///