]> granicus.if.org Git - handbrake/commitdiff
WinGui: Attempt to fix the the exception handling when AccessViolations occur.
authorsr55 <sr55.hb@outlook.com>
Sat, 16 Feb 2019 21:21:54 +0000 (21:21 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 16 Feb 2019 21:21:54 +0000 (21:21 +0000)
win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs

index 9c499c9c5c03d9d78267eb8f266ee0779c936fdb..77201bc3842c9834cf5d3f79c0d59c2d843e460c 100644 (file)
@@ -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>