From 73c528c06ec24e5b40f7456e8cd16f8a05f87f92 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 21 May 2011 20:12:02 +0000 Subject: WinGui: Add Exported Preset contents to the error dialog for the presets service for debugging. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3992 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Services/PresetService.cs | 76 +++++++++++----------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs index c3bfa7fb7..75d9805cc 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs @@ -11,6 +11,7 @@ namespace HandBrake.ApplicationServices.Services using System.Diagnostics; using System.IO; using System.Linq; + using System.Text; using System.Text.RegularExpressions; using System.Windows; using System.Xml.Serialization; @@ -222,55 +223,56 @@ namespace HandBrake.ApplicationServices.Services if (File.Exists(presetsPath)) { - StreamReader presetInput = new StreamReader(presetsPath); - - string category = String.Empty; - - while (!presetInput.EndOfStream) + using (StreamReader presetInput = new StreamReader(presetsPath)) { - string line = presetInput.ReadLine(); + StringBuilder contents = new StringBuilder(); - // Found the beginning of a preset block - if (line != null && line.Contains("<") && !line.Contains("<<")) - { - category = line.Replace("<", string.Empty).Trim(); - } + string category = String.Empty; - // Found a preset - if (line != null && line.Contains("+")) + while (!presetInput.EndOfStream) { - Regex r = new Regex("(: )"); // Split on hyphens. - string[] presetName = r.Split(line); + string line = presetInput.ReadLine(); + contents.AppendLine(line); - bool pic = false; - if (presetName[2].Contains("crop")) + // Found the beginning of a preset block ) + if (line != null && line.Contains("<") && !line.Contains("<<")) { - pic = true; + category = line.Replace("<", string.Empty).Trim(); } - Preset newPreset = new Preset + // Found a preset + if (line != null && line.Contains("+")) + { + Regex r = new Regex("(: )"); // Split on hyphens. + string[] presetName = r.Split(line); + + bool pic = false; + if (presetName[2].Contains("crop")) { - Category = category, - Name = presetName[0].Replace("+", string.Empty).Trim(), - Query = presetName[2], - Version = Properties.Settings.Default.HandBrakeVersion, - CropSettings = pic, - Description = string.Empty, // Maybe one day we will populate this. - IsBuildIn = true - }; - - this.presets.Add(newPreset); + pic = true; + } + + Preset newPreset = new Preset + { + Category = category, + Name = presetName[0].Replace("+", string.Empty).Trim(), + Query = presetName[2], + Version = Properties.Settings.Default.HandBrakeVersion, + CropSettings = pic, + Description = string.Empty, // Maybe one day we will populate this. + IsBuildIn = true + }; + + this.presets.Add(newPreset); + } } - } - // Verify we have presets. - if (this.presets.Count == 0) - { - throw new GeneralApplicationException("Failed to load built-in presets.", "Restarting HandBrake may resolve this issue", null); + // Verify we have presets. + if (this.presets.Count == 0) + { + throw new GeneralApplicationException("Failed to load built-in presets.", "Restarting HandBrake may resolve this issue", new Exception(contents.ToString())); + } } - - presetInput.Close(); - presetInput.Dispose(); } else { -- cgit v1.2.3