]> granicus.if.org Git - handbrake/commitdiff
WinGui: Fix a couple of trival gui bugs and force all exceptions to be handled by...
authorsr55 <sr55.hb@outlook.com>
Wed, 15 Feb 2012 20:03:10 +0000 (20:03 +0000)
committersr55 <sr55.hb@outlook.com>
Wed, 15 Feb 2012 20:03:10 +0000 (20:03 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4449 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/Functions/Main.cs
win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs
win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs
win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
win/CS/HandBrakeCS.csproj
win/CS/Program.cs
win/CS/frmMain.Designer.cs

index 9411fc151d3f1e162ce25401217fdf8e13fa24bf..42b1034981366c7703333443e17708f226599f32 100644 (file)
@@ -100,19 +100,21 @@ namespace Handbrake.Functions
             IDictionary<int, string> chapterMap = new Dictionary<int, string>();\r
             try\r
             {\r
-                StreamReader sr = new StreamReader(filename);\r
-                string csv = sr.ReadLine();\r
-                while (csv != null)\r
+                using (StreamReader sr = new StreamReader(filename))\r
                 {\r
-                    if (csv.Trim() != string.Empty)\r
+                    string csv = sr.ReadLine();\r
+                    while (csv != null)\r
                     {\r
-                        csv = csv.Replace("\\,", "<!comma!>");\r
-                        string[] contents = csv.Split(',');\r
-                        int chapter;\r
-                        int.TryParse(contents[0], out chapter);\r
-                        chapterMap.Add(chapter, contents[1].Replace("<!comma!>", ","));\r
+                        if (csv.Trim() != string.Empty)\r
+                        {\r
+                            csv = csv.Replace("\\,", "<!comma!>");\r
+                            string[] contents = csv.Split(',');\r
+                            int chapter;\r
+                            int.TryParse(contents[0], out chapter);\r
+                            chapterMap.Add(chapter, contents[1].Replace("<!comma!>", ","));\r
+                        }\r
+                        csv = sr.ReadLine();\r
                     }\r
-                    csv = sr.ReadLine();\r
                 }\r
             }\r
             catch (Exception)\r
@@ -156,7 +158,7 @@ namespace Handbrake.Functions
             }\r
             catch (Exception exc)\r
             {\r
-                throw new GeneralApplicationException("Unable to save Chapter Makrers file! ", "Chapter marker names will NOT be saved in your encode.", exc);\r
+                throw new GeneralApplicationException("Unable to save the chapter information to csv.", "The file may already be in use by another application.", exc);\r
             }\r
         }\r
 \r
index b4a23231e73bb120c1785a16357a61f5a5dbb5d1..84c6252a21ff127ebe92ac1ec84607ebe49388eb 100644 (file)
@@ -10,6 +10,7 @@ namespace HandBrake.ApplicationServices.Services.Base
     using System.Text;\r
 \r
     using HandBrake.ApplicationServices.EventArgs;\r
+    using HandBrake.ApplicationServices.Exceptions;\r
     using HandBrake.ApplicationServices.Functions;\r
     using HandBrake.ApplicationServices.Model;\r
     using HandBrake.ApplicationServices.Services.Interfaces;\r
@@ -59,7 +60,7 @@ namespace HandBrake.ApplicationServices.Services.Base
         /// </summary>\r
         public EncodeBase()\r
         {\r
-            this.logBuffer = new StringBuilder();  \r
+            this.logBuffer = new StringBuilder();\r
         }\r
 \r
         #region Events\r
@@ -363,18 +364,18 @@ namespace HandBrake.ApplicationServices.Services.Base
         protected void VerifyEncodeDestinationPath(QueueTask task)\r
         {\r
             // Make sure the path exists, attempt to create it if it doesn't\r
-            string path = Directory.GetParent(task.Destination).ToString();\r
-            if (!Directory.Exists(path))\r
+            try\r
             {\r
-                try\r
+                string path = Directory.GetParent(task.Destination).ToString();\r
+                if (!Directory.Exists(path))\r
                 {\r
                     Directory.CreateDirectory(path);\r
                 }\r
-                catch (Exception)\r
-                {\r
-                    throw new Exception(\r
-                        "Unable to create directory for the encoded output. Please verify the drive and path is correct.");\r
-                }\r
+            }\r
+            catch (Exception exc)\r
+            {\r
+                throw new GeneralApplicationException(\r
+                    "Unable to create directory for the encoded output.", "Please verify that you have a valid path.", exc);\r
             }\r
         }\r
 \r
index 6cddd2707ce628248a614c92e9559cf21a4c44c8..7c60d1e86cb975646a6f3e578a20062cdad53186 100644 (file)
@@ -322,7 +322,16 @@ namespace HandBrake.ApplicationServices.Services
                     {\r
                         XmlSerializer serializer = new XmlSerializer(typeof(List<QueueTask>));\r
 \r
-                        List<QueueTask> list = serializer.Deserialize(strm) as List<QueueTask>;\r
+                        List<QueueTask> list;\r
+\r
+                        try\r
+                        {\r
+                            list = serializer.Deserialize(strm) as List<QueueTask>; \r
+                        }\r
+                        catch (Exception exc)\r
+                        {\r
+                            throw new GeneralApplicationException("Unable to restore queue file.", "The file may be corrupted or from an older incompatible version of HandBrake", exc);\r
+                        }\r
 \r
                         if (list != null)\r
                             foreach (QueueTask item in list)\r
index e9342ca4e37ce1c630ea2d10a2cc7ff00ad5056f..ce3a756edb2dc009f6d0ba8c26a4e234ef184d90 100644 (file)
@@ -210,6 +210,10 @@ namespace HandBrake.ApplicationServices.Services
             {\r
                 this.QueueManager.LastProcessedJob.Status = QueueItemStatus.Error;\r
                 this.Pause();\r
+                if (e.Exception.GetType() == typeof(GeneralApplicationException))\r
+                {\r
+                    throw e.Exception;\r
+                }\r
                 throw new GeneralApplicationException(e.ErrorInformation, e.Exception.Message, e.Exception);\r
             }\r
 \r
index 9bec51e5503a3be09e7d21b9ac1189f38c463c7b..117881d89667805c305c253d78d7fdd28667e201 100644 (file)
@@ -22,6 +22,7 @@
     <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>\r
     <IsWebBootstrapper>false</IsWebBootstrapper>\r
     <SignManifests>false</SignManifests>\r
+    <TargetFrameworkProfile>Client</TargetFrameworkProfile>\r
     <PublishUrl>publish\</PublishUrl>\r
     <Install>true</Install>\r
     <InstallFrom>Disk</InstallFrom>\r
@@ -36,7 +37,6 @@
     <ApplicationVersion>1.0.0.%2a</ApplicationVersion>\r
     <UseApplicationTrust>false</UseApplicationTrust>\r
     <BootstrapperEnabled>true</BootstrapperEnabled>\r
-    <TargetFrameworkProfile>Client</TargetFrameworkProfile>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">\r
     <PlatformTarget>x86</PlatformTarget>\r
@@ -48,7 +48,8 @@
     <PlatformTarget>x86</PlatformTarget>\r
     <OutputPath>bin\x86\Release\</OutputPath>\r
     <UseVSHostingProcess>false</UseVSHostingProcess>\r
-    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+    <DefineConstants>\r
+    </DefineConstants>\r
     <Optimize>true</Optimize>\r
     <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>\r
   </PropertyGroup>\r
index 9939bfa425c2b6059cf18a033bf16a85cd55fbde..fca7b0217dd66e8f8378f2852d64b879dd3ddf98 100644 (file)
@@ -35,6 +35,7 @@ namespace Handbrake
 \r
             // Handle any unhandled exceptions\r
             AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;\r
+            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);\r
 \r
             // Check that HandBrakeCLI is availabl.\r
             string failedInstall = "HandBrake is not installed properly. Please reinstall HandBrake. \n\n";\r
index a53663b4dab06517b4dbd49100ea4975107353f1..8f1345b51ae2105992d4746ceb641c5359130b26 100644 (file)
@@ -416,7 +416,7 @@ namespace Handbrake
             this.ChaptersMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
             this.mnu_resetChapters});\r
             this.ChaptersMenu.Name = "presets_menu";\r
-            this.ChaptersMenu.OwnerItem = this.btn_file_source;\r
+            this.ChaptersMenu.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;\r
             this.ChaptersMenu.Size = new System.Drawing.Size(188, 26);\r
             this.ChaptersMenu.Text = ";";\r
             // \r