]> granicus.if.org Git - handbrake/commitdiff
WinGui: Add HandleProcessCorruptedStateExceptions around Init.
authorsr55 <sr55.hb@outlook.com>
Sat, 16 Feb 2019 18:04:49 +0000 (18:04 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 16 Feb 2019 21:28:39 +0000 (21:28 +0000)
win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs

index 7f36a406ca0e4461ac3d5bd7e539f695225e6a2b..9c499c9c5c03d9d78267eb8f266ee0779c936fdb 100644 (file)
@@ -13,6 +13,7 @@ namespace HandBrake.Interop.Interop
     using System.Collections.Generic;
     using System.Linq.Expressions;
     using System.Runtime.CompilerServices;
+    using System.Runtime.ExceptionServices;
     using System.Runtime.InteropServices;
 
     using HandBrake.Interop.Interop.EventArgs;
@@ -64,11 +65,7 @@ namespace HandBrake.Interop.Interop
             {
                 try
                 {
-
-                    if (HBFunctions.hb_global_init() == -1)
-                    {
-                        throw new InvalidOperationException("HB global init failed.");
-                    }
+                    TryInit();
                 }
                 catch (Exception e)
                 {
@@ -88,6 +85,15 @@ namespace HandBrake.Interop.Interop
             }
         }
 
+        [HandleProcessCorruptedStateExceptions]
+        static void TryInit()
+        {
+            if (HBFunctions.hb_global_init() == -1)
+            {
+                throw new InvalidOperationException("HB global init failed.");
+            }
+        }
+
         /// <summary>
         /// Ensures the HB global initialize method has been called.
         /// </summary>