]> granicus.if.org Git - handbrake/commitdiff
WinGui: Fix a possible crash after scanning a source.
authorsr55 <sr55.hb@outlook.com>
Mon, 23 Jul 2012 14:22:23 +0000 (14:22 +0000)
committersr55 <sr55.hb@outlook.com>
Mon, 23 Jul 2012 14:22:23 +0000 (14:22 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4871 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
win/CS/HandBrake.ApplicationServices/Parsing/Title.cs
win/CS/HandBrake.ApplicationServices/Utilities/PlistHelper.cs [deleted file]
win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs

index 705911f4a601dd3305e2f01e09d159a9388326ef..4fc9b2fadf1222611742d30e49abb0358f1e7943 100644 (file)
     <Compile Include="Utilities\EnumHelper.cs" />\r
     <Compile Include="Utilities\GrowlCommunicator.cs" />\r
     <Compile Include="Utilities\InteropModelCreator.cs" />\r
-    <Compile Include="Utilities\PlistHelper.cs" />\r
     <Compile Include="Utilities\SystemInfo.cs" />\r
     <Compile Include="Utilities\Win32.cs" />\r
     <Compile Include="Utilities\Win7.cs" />\r
index 454627fa9a52ca4a4b023d1755ec180b047bfec1..a77b8430691682e9cc7a40f0ec07f57d53fae1e5 100644 (file)
@@ -266,7 +266,7 @@ namespace HandBrake.ApplicationServices.Parsing
         /// <returns>A string representing this track in the format: {title #} (00:00:00)</returns>\r
         public override string ToString()\r
         {\r
-            if (!string.IsNullOrEmpty(this.Playlist))\r
+            if (!string.IsNullOrEmpty(this.Playlist) && !this.Playlist.StartsWith(" "))\r
             {\r
                 this.Playlist = string.Format(" {0}", this.Playlist);\r
             }\r
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistHelper.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistHelper.cs
deleted file mode 100644 (file)
index f5e8107..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------\r
-// <copyright file="PlistHelper.cs" company="HandBrake Project (http://handbrake.fr)">\r
-//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
-// </copyright>\r
-// <summary>\r
-//   A Plist Helper\r
-// </summary>\r
-// --------------------------------------------------------------------------------------------------------------------\r
-\r
-namespace HandBrake.ApplicationServices.Utilities\r
-{\r
-    using System;\r
-    using System.Collections.Generic;\r
-    using System.IO;\r
-    using System.Xml;\r
-\r
-    /// <summary>\r
-    /// A Plist Helper\r
-    /// </summary>\r
-    public class PlistHelper\r
-    {\r
-        /// <summary>\r
-        /// Get the Audio Track XML Nodes from a plist preset file\r
-        /// </summary>\r
-        /// <param name="filename">\r
-        /// A Plist preset file\r
-        /// </param>\r
-        /// <returns>\r
-        /// A List of XmlNodes which contain audio tracks\r
-        /// </returns>\r
-        public static List<XmlNode> GetAudioTracks(string filename)\r
-        {\r
-            // Data Store\r
-            List<XmlNode> audioTracks = new List<XmlNode>();\r
-\r
-            // Load the file and get the Root note, or return if none found\r
-            XmlNode root = LoadFile(filename);\r
-            if (root == null)\r
-            {\r
-                return null;\r
-            }\r
-\r
-            // Get the Audio Tracks\r
-            XmlNode audioListDict = root.ChildNodes[2].ChildNodes[0].FirstChild.ChildNodes[1];\r
-            for (int i = 0; i < audioListDict.ChildNodes.Count; i++)\r
-            {\r
-                XmlNode audioChannel = audioListDict.ChildNodes[i]; // <dict>\r
-                audioTracks.Add(audioChannel);\r
-            }\r
-\r
-            return audioTracks;\r
-        }\r
-\r
-        /// <summary>\r
-        /// Get the settings portion of a presets file\r
-        /// </summary>\r
-        /// <param name="filename">\r
-        /// A Plist preset file\r
-        /// </param>\r
-        /// <returns>\r
-        /// A Dictionary of plist key against an XML node containing the setting.\r
-        /// </returns>\r
-        public static Dictionary<string, XmlNode> GetPresetSettings(string filename)\r
-        {\r
-            // Data Store\r
-            Dictionary<string, XmlNode> settings = new Dictionary<string, XmlNode>();\r
-\r
-            // Load the file and get the Root note, or return if none found\r
-            XmlNode root = LoadFile(filename);\r
-            if (root == null)\r
-            {\r
-                return null;\r
-            }\r
-\r
-            // Get the Preset Settings, starting from the 3rd node (skipping the audio notes we've just prcessed)\r
-            XmlNode presetSettings = root.ChildNodes[2].ChildNodes[0].FirstChild;\r
-            for (int i = 2; i < presetSettings.ChildNodes.Count; i += 2)\r
-            {\r
-                string key = presetSettings.ChildNodes[i].InnerText;\r
-                XmlNode node = presetSettings.ChildNodes[i + 1];\r
-                settings.Add(key, node);\r
-            }\r
-\r
-            return settings;\r
-        }\r
-\r
-        /// <summary>\r
-        /// Load a Plist Preset file and return it as an XML document\r
-        /// </summary>\r
-        /// <param name="filename">\r
-        /// A Plist preset file\r
-        /// </param>\r
-        /// <returns>\r
-        /// An XML document\r
-        /// </returns>\r
-        private static XmlNode LoadFile(string filename)\r
-        {\r
-            try\r
-            {\r
-                if (!File.Exists(filename))\r
-                {\r
-                    return null;\r
-                }\r
-\r
-                StreamReader sr = File.OpenText(filename);\r
-                string fromfile = string.Empty;\r
-                int fileChar;\r
-                while ((fileChar = sr.Read()) != -1)\r
-                {\r
-                    fromfile += Convert.ToChar(fileChar);\r
-                }\r
-\r
-                XmlDocument doc = new XmlDocument();\r
-                doc.LoadXml(fromfile);\r
-\r
-                XmlNode root = doc;\r
-                if (!root.HasChildNodes)\r
-                {\r
-                    return null;\r
-                }\r
-\r
-                return root;\r
-            }\r
-            catch (Exception)\r
-            {\r
-                return null;\r
-            }\r
-        }\r
-    }\r
-}\r
index c1df4b8be42d9e71b9e499ff41f2d18a62b5084c..30f884779e77ee81685292f2cfb7c271d179524d 100644 (file)
@@ -634,11 +634,11 @@ namespace HandBrakeWPF.ViewModels
             }\r
             set\r
             {\r
-                if (!Equals(this.selectedTitle, value))\r
+                if (!object.Equals(this.selectedTitle, value))\r
                 {\r
                     this.selectedTitle = value;\r
 \r
-                    if (selectedTitle == null)\r
+                    if (this.selectedTitle == null)\r
                     {\r
                         return;\r
                     }\r
@@ -652,7 +652,11 @@ namespace HandBrakeWPF.ViewModels
 \r
                     // Default the Start and End Point dropdowns\r
                     this.SelectedStartPoint = 1;\r
-                    this.SelectedEndPoint = selectedTitle.Chapters.Last().ChapterNumber;\r
+                    this.SelectedEndPoint = this.selectedTitle.Chapters != null &&\r
+                                            this.selectedTitle.Chapters.Count != 0\r
+                                                ? this.selectedTitle.Chapters.Last().ChapterNumber\r
+                                                : 1;\r
+\r
                     this.SelectedPointToPoint = PointToPointMode.Chapters;\r
                     this.SelectedAngle = 1;\r
 \r
@@ -662,7 +666,7 @@ namespace HandBrakeWPF.ViewModels
                     }\r
                     this.NotifyOfPropertyChange(() => this.CurrentTask);\r
 \r
-                    this.Duration = selectedTitle.Duration.ToString();\r
+                    this.Duration = this.selectedTitle.Duration.ToString();\r
 \r
                     // Setup the tab controls\r
                     this.SetupTabs();\r