summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.Interop
diff options
context:
space:
mode:
authorsr55 <[email protected]>2019-02-16 21:21:54 +0000
committersr55 <[email protected]>2019-02-16 21:21:54 +0000
commite6cd082d696cc37b8bbd8812486f5639016238a0 (patch)
tree7afc57afd42e71c56613d6adf93d4f85a63fed85 /win/CS/HandBrake.Interop
parentce660242a4ad016cccbe51cd4cf1f402cb14bb44 (diff)
WinGui: Attempt to fix the the exception handling when AccessViolations occur.
Diffstat (limited to 'win/CS/HandBrake.Interop')
-rw-r--r--win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs25
1 files changed, 21 insertions, 4 deletions
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;
}
/// <summary>