]> granicus.if.org Git - handbrake/commitdiff
WinGui:
authorsr55 <sr55.hb@outlook.com>
Wed, 22 Aug 2007 18:48:40 +0000 (18:48 +0000)
committersr55 <sr55.hb@outlook.com>
Wed, 22 Aug 2007 18:48:40 +0000 (18:48 +0000)
- Added some more exception handling.
- Added workaround for issue with scanning on French systems causing a crash.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@850 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/Parsing/DVD.cs
win/C#/Parsing/Title.cs
win/C#/frmDebug.cs
win/C#/frmMain.cs
win/C#/frmReadDVD.cs

index 3ba212022f7f5915e8123fbe341d052ccfa4f791..3249a23aa0bb438814a6c171d4cb12f783776dfc 100644 (file)
@@ -1,17 +1,23 @@
 using System;\r
 using System.Collections.Generic;\r
+using System.ComponentModel;\r
+using System.Data;\r
+using System.Drawing;\r
 using System.Text;\r
-using System.IO;\r
-using System.Text.RegularExpressions;\r
 using System.Windows.Forms;\r
+using System.IO;\r
+using System.Threading;\r
+using System.Diagnostics;\r
 \r
 namespace Handbrake.Parsing\r
 {\r
+    \r
     /// <summary>\r
     /// An object representing a scanned DVD\r
     /// </summary>\r
     public class DVD\r
     {\r
+\r
         private List<Title> m_titles;\r
         /// <summary>\r
         /// Collection of Titles associated with this DVD\r
@@ -39,11 +45,12 @@ namespace Handbrake.Parsing
             {\r
                 if ((char)output.Peek() == '+')\r
                 {\r
-                    thisDVD.m_titles.AddRange(Title.ParseList(output.ReadToEnd()));\r
+                    string testb = output.ReadToEnd();\r
+                    thisDVD.m_titles.AddRange(Title.ParseList(testb));\r
                 }\r
                 else\r
                 {\r
-                    output.ReadLine();\r
+                    string test = output.ReadLine();\r
                 }\r
             }\r
             return thisDVD;\r
index 933be6d2d3aa4143fa64454dbfd647a32b9e0ba2..a78fef78a50f707127c02a67960389af7cd1672a 100644 (file)
@@ -85,11 +85,11 @@ namespace Handbrake.Parsing
             }\r
         }\r
 \r
-        private float m_aspectRatio;\r
+        private string m_aspectRatio;\r
         /// <summary>\r
         /// The aspect ratio of this Title\r
         /// </summary>\r
-        public float AspectRatio\r
+        public string AspectRatio\r
         {\r
             get\r
             {\r
@@ -139,71 +139,48 @@ namespace Handbrake.Parsing
             Title thisTitle = new Title();\r
 \r
             // Match track number for this title\r
-            Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):");\r
-            if (m.Success)\r
+            try\r
             {\r
-                thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value);\r
-            }\r
-\r
-            output.ReadLine();\r
-            /*\r
-            // Match vts, ttn, cell range and block count\r
-            m = Regex.Match(output.ReadLine(), @"^  \+ vts ([0-9]*), ttn ([0-9]*), cells ([0-9]*)->([0-9]*) \(([0-9]*) blocks\)");\r
-            if (m.Success)\r
-            {\r
-                // We don't need any of those values right now, so we'll just ignore them\r
-                // and read a line from the buffer to get it out of the way.\r
-            }\r
-            */\r
 \r
-            // Get duration for this title\r
-            m = Regex.Match(output.ReadLine(), @"^  \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})");\r
-            if (m.Success)\r
-            {\r
-                thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value);\r
+                Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):");\r
+                if (m.Success)\r
+                {\r
+                    thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value);\r
+                }\r
+                output.ReadLine();\r
+\r
+                // Get duration for this title\r
+                m = Regex.Match(output.ReadLine(), @"^  \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})");\r
+                if (m.Success)\r
+                {\r
+                    thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value);\r
+                }\r
+\r
+                // Get resolution, aspect ratio and FPS for this title\r
+                m = Regex.Match(output.ReadLine(), @"^  \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");\r
+                if (m.Success)\r
+                {\r
+                    thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));\r
+                    thisTitle.m_aspectRatio = m.Groups[3].ToString(); // Converted to a String for French Lanuage based systems. Some weird exception thrown\r
+                                                                      // when trying to parse it as a float\r
+                    // we don't need FPS right now\r
+                }\r
+\r
+                // Get autocrop region for this title\r
+                m = Regex.Match(output.ReadLine(), @"^  \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)");\r
+                if (m.Success)\r
+                {\r
+                    thisTitle.m_autoCrop = new int[4] { int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value) };\r
+                }\r
+\r
+                thisTitle.m_chapters.AddRange(Chapter.ParseList(output));\r
+                thisTitle.m_audioTracks.AddRange(AudioTrack.ParseList(output));\r
+                thisTitle.m_subtitles.AddRange(Subtitle.ParseList(output));\r
             }\r
-\r
-            // Get resolution, aspect ratio and FPS for this title\r
-            m = Regex.Match(output.ReadLine(), @"^  \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");\r
-            if (m.Success)\r
+            catch (Exception exc)\r
             {\r
-                thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));\r
-                thisTitle.m_aspectRatio = float.Parse(m.Groups[3].Value);\r
-                // we don't need FPS right now\r
+                MessageBox.Show(exc.ToString());\r
             }\r
-\r
-            // Get autocrop region for this title\r
-            m = Regex.Match(output.ReadLine(), @"^  \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)");\r
-            if (m.Success)\r
-            {\r
-                thisTitle.m_autoCrop = new int[4] { int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value) };\r
-            }\r
-\r
-            /* \r
-             * \r
-             * A Few Bugs that need fixed.\r
-             * \r
-             * \r
-             * Problem 1\r
-             * There is a small problem here... What happens if the DVD has no Subtitles? or Handbrake misses the Audio or Chapter track \r
-             * data due to an error.\r
-             * \r
-             * hbcli will sit in a suspended state until it is forcefully closed.\r
-             * \r
-             * Problem 2\r
-             * See AudioTrack.cs Line 80 for details\r
-             * \r
-             * Problem 3\r
-             * Doesn't seem to support DVD's where the first track is 0 instead of 1, and only includes 1 title (TS/MPG files)\r
-             * Simply Doesn't list any titles.\r
-             * \r
-             * \r
-             */\r
-\r
-            thisTitle.m_chapters.AddRange(Chapter.ParseList(output));\r
-            thisTitle.m_audioTracks.AddRange(AudioTrack.ParseList(output));\r
-            thisTitle.m_subtitles.AddRange(Subtitle.ParseList(output));\r
-\r
             return thisTitle;\r
         }\r
 \r
index 450bc088bbbdf48ecdbece7c4d126e72cd8a2d60..a6d05b197b5610ebc367349cef3f6e988e73a85c 100644 (file)
@@ -19,5 +19,6 @@ namespace Handbrake
         {\r
             this.Close();\r
         }\r
+\r
     }\r
 }
\ No newline at end of file
index c70b71c9fed416398e352d997658b6fe0ac532b3..d3873c407f4c6d52df1dc9a37beebd96787d12a7 100644 (file)
@@ -1228,9 +1228,10 @@ namespace Handbrake
                     }\r
                 }\r
             }\r
-            catch (Exception)\r
+            catch (Exception exc)\r
             {\r
                 // No need to throw an error here.\r
+                // Note on non english systems, this will throw an error because of double.Parse(lbl_Aspect.Text); not working.\r
             }\r
                \r
           \r
index ca6d23342882f25ae71c23cfd6ccfe4714e80bd8..ad5551188c6050a87570ec977e7f1e5c5ac11a70 100644 (file)
@@ -20,7 +20,7 @@ namespace Handbrake
         private Parsing.DVD thisDvd;\r
         private Process hbProc;\r
         private delegate void UpdateUIHandler();\r
-        private int cancel = 0;\r
+        //private int cancel = 0;\r
 \r
         public frmReadDVD(string inputFile, frmMain parent, frmDvdInfo dvdInfoWindow)\r
         {\r
@@ -32,7 +32,7 @@ namespace Handbrake
 \r
         private void btn_ok_Click(object sender, EventArgs e)\r
         {\r
-            \r
+      \r
             try\r
             {\r
                 btn_ok.Enabled = false;\r
@@ -90,22 +90,27 @@ namespace Handbrake
                 string strCmdLine = "cmd /c " + '"' + '"' + appPath + "\\hbcli.exe" + '"' +  " -i" + '"' + inputFile + '"' + " -t0 >" + '"'+ appPath + "\\dvdinfo.dat" + '"' + " 2>&1" + '"';\r
                 Process hbproc = Process.Start("CMD.exe", strCmdLine);\r
                 hbproc.WaitForExit();\r
+                hbproc.Dispose();\r
+                hbproc.Close();\r
 \r
           \r
                 StreamReader sr = new StreamReader(appPath + "dvdinfo.dat");\r
-        \r
                 thisDvd = Parsing.DVD.Parse(sr);\r
 \r
                 sr.Close();\r
+\r
                 Console.ReadLine();\r
+\r
                 updateUIElements();\r
             }\r
             catch (Exception exc)\r
             {\r
                 MessageBox.Show(exc.ToString());\r
             }\r
-            //*********************************************************************************************************************************************\r
 \r
+        }\r
+\r
+            //*********************************************************************************************************************************************\r
             /*\r
              * This has been temporily disabled due to the stderr issue\r
              * \r
@@ -125,7 +130,8 @@ namespace Handbrake
                 process.closeCLI();\r
             }\r
             */\r
-        }\r
+            //*********************************************************************************************************************************************\r
+\r
 \r
         /*private void Parser_OnScanProgress(object Sender, int CurrentTitle, int TitleCount)\r
         {\r
@@ -147,7 +153,7 @@ namespace Handbrake
             try\r
             {\r
                 this.Close();\r
-                cancel = 1;\r
+                //cancel = 1;\r
             }\r
             catch (Exception exc)\r
             {\r