OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / Program.cs
index 9596676..9c45464 100644 (file)
@@ -21,6 +21,8 @@ namespace Handbrake
         [STAThread]\r
         public static void Main()\r
         {\r
+            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);\r
+\r
             const string failedInstall = "HandBrake is not installed properly. Please reinstall HandBrake. \n\n";\r
             const string nightlyCLIMissing =\r
                 "If you have downloaded the \"HandBrakeGUI\" nightly, " +\r
@@ -33,16 +35,33 @@ namespace Handbrake
                 missingFiles += "\"HandBrakeCLI.exe\" was not found.";\r
             }\r
 \r
-            if (!File.Exists(Path.Combine(Application.StartupPath, "libgcc_s_sjlj-1.dll")))\r
+            if (missingFiles != string.Empty)\r
             {\r
-                missingFiles += "\n\"libgcc_s_sjlj-1.dll\" was not found.";\r
+                MessageBox.Show(\r
+                    failedInstall + missingFiles + "\n\n" + nightlyCLIMissing,\r
+                    "Error",\r
+                    MessageBoxButtons.OK,\r
+                    MessageBoxIcon.Error);\r
+                return;\r
             }\r
 \r
-            if (missingFiles != string.Empty)\r
+            // Make sure we have a recent version for svn builds\r
+            string version = Properties.Settings.Default.hb_version;\r
+            if (version.Contains("svn"))\r
             {\r
-                MessageBox.Show(failedInstall + missingFiles + "\n\n"+ nightlyCLIMissing, "Error", MessageBoxButtons.OK,\r
-                                MessageBoxIcon.Error);\r
-                return;\r
+                version = version.Replace("svn", string.Empty).Trim();\r
+                int build;\r
+                int.TryParse(version, out build);\r
+                if (build < Properties.Settings.Default.hb_min_cli)\r
+                {\r
+                    MessageBox.Show(\r
+                        "It appears you are trying to use a CLI executable that is too old for this version of the HandBrake GUI.\n" + \r
+                        "Please update the HandBrakeCLI.exe to a newer build. ",\r
+                        "Error",\r
+                        MessageBoxButtons.OK,\r
+                        MessageBoxIcon.Error);\r
+                    return;\r
+                }\r
             }\r
 \r
             // Check were not running on a screen that's going to cause some funnies to happen.\r
@@ -66,5 +85,19 @@ namespace Handbrake
                 Application.Run(new frmMain());\r
             }\r
         }\r
+\r
+        /// <summary>\r
+        /// Throw up an error message for any unhandled exceptions.\r
+        /// </summary>\r
+        /// <param name="sender">The sender</param>\r
+        /// <param name="e">Unhandled Exception EventArgs </param>\r
+        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)\r
+        {\r
+            MessageBox.Show(\r
+                "An unexpected error has occured.\n\nSender:" + sender + "\n\nException:" + e.ExceptionObject, \r
+                "Unhandled Exception",\r
+                MessageBoxButtons.OK,\r
+                MessageBoxIcon.Error);\r
+        }\r
     }\r
 }
\ No newline at end of file