summaryrefslogtreecommitdiffstats
path: root/win/CS
diff options
context:
space:
mode:
authorsr55 <[email protected]>2012-02-15 20:03:10 +0000
committersr55 <[email protected]>2012-02-15 20:03:10 +0000
commit1d8bc5dd7d36da0167e572762b6f20db20289012 (patch)
tree20e3a5164ff24bb6d44504e587fb14dc9a92d5bd /win/CS
parent4da15bcbbbd800b7af230294224f0d7248e8dd72 (diff)
WinGui: Fix a couple of trival gui bugs and force all exceptions to be handled by the built-in exception handler rather than the .NET one.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4449 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS')
-rw-r--r--win/CS/Functions/Main.cs24
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs19
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs11
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs4
-rw-r--r--win/CS/HandBrakeCS.csproj5
-rw-r--r--win/CS/Program.cs1
-rw-r--r--win/CS/frmMain.Designer.cs2
7 files changed, 42 insertions, 24 deletions
diff --git a/win/CS/Functions/Main.cs b/win/CS/Functions/Main.cs
index 9411fc151..42b103498 100644
--- a/win/CS/Functions/Main.cs
+++ b/win/CS/Functions/Main.cs
@@ -100,19 +100,21 @@ namespace Handbrake.Functions
IDictionary<int, string> chapterMap = new Dictionary<int, string>();
try
{
- StreamReader sr = new StreamReader(filename);
- string csv = sr.ReadLine();
- while (csv != null)
+ using (StreamReader sr = new StreamReader(filename))
{
- if (csv.Trim() != string.Empty)
+ string csv = sr.ReadLine();
+ while (csv != null)
{
- csv = csv.Replace("\\,", "<!comma!>");
- string[] contents = csv.Split(',');
- int chapter;
- int.TryParse(contents[0], out chapter);
- chapterMap.Add(chapter, contents[1].Replace("<!comma!>", ","));
+ if (csv.Trim() != string.Empty)
+ {
+ csv = csv.Replace("\\,", "<!comma!>");
+ string[] contents = csv.Split(',');
+ int chapter;
+ int.TryParse(contents[0], out chapter);
+ chapterMap.Add(chapter, contents[1].Replace("<!comma!>", ","));
+ }
+ csv = sr.ReadLine();
}
- csv = sr.ReadLine();
}
}
catch (Exception)
@@ -156,7 +158,7 @@ namespace Handbrake.Functions
}
catch (Exception exc)
{
- throw new GeneralApplicationException("Unable to save Chapter Makrers file! ", "Chapter marker names will NOT be saved in your encode.", exc);
+ throw new GeneralApplicationException("Unable to save the chapter information to csv.", "The file may already be in use by another application.", exc);
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs
index b4a23231e..84c6252a2 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Base/EncodeBase.cs
@@ -10,6 +10,7 @@ namespace HandBrake.ApplicationServices.Services.Base
using System.Text;
using HandBrake.ApplicationServices.EventArgs;
+ using HandBrake.ApplicationServices.Exceptions;
using HandBrake.ApplicationServices.Functions;
using HandBrake.ApplicationServices.Model;
using HandBrake.ApplicationServices.Services.Interfaces;
@@ -59,7 +60,7 @@ namespace HandBrake.ApplicationServices.Services.Base
/// </summary>
public EncodeBase()
{
- this.logBuffer = new StringBuilder();
+ this.logBuffer = new StringBuilder();
}
#region Events
@@ -363,18 +364,18 @@ namespace HandBrake.ApplicationServices.Services.Base
protected void VerifyEncodeDestinationPath(QueueTask task)
{
// Make sure the path exists, attempt to create it if it doesn't
- string path = Directory.GetParent(task.Destination).ToString();
- if (!Directory.Exists(path))
+ try
{
- try
+ string path = Directory.GetParent(task.Destination).ToString();
+ if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
- catch (Exception)
- {
- throw new Exception(
- "Unable to create directory for the encoded output. Please verify the drive and path is correct.");
- }
+ }
+ catch (Exception exc)
+ {
+ throw new GeneralApplicationException(
+ "Unable to create directory for the encoded output.", "Please verify that you have a valid path.", exc);
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs
index 6cddd2707..7c60d1e86 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/QueueManager.cs
@@ -322,7 +322,16 @@ namespace HandBrake.ApplicationServices.Services
{
XmlSerializer serializer = new XmlSerializer(typeof(List<QueueTask>));
- List<QueueTask> list = serializer.Deserialize(strm) as List<QueueTask>;
+ List<QueueTask> list;
+
+ try
+ {
+ list = serializer.Deserialize(strm) as List<QueueTask>;
+ }
+ catch (Exception exc)
+ {
+ throw new GeneralApplicationException("Unable to restore queue file.", "The file may be corrupted or from an older incompatible version of HandBrake", exc);
+ }
if (list != null)
foreach (QueueTask item in list)
diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
index e9342ca4e..ce3a756ed 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs
@@ -210,6 +210,10 @@ namespace HandBrake.ApplicationServices.Services
{
this.QueueManager.LastProcessedJob.Status = QueueItemStatus.Error;
this.Pause();
+ if (e.Exception.GetType() == typeof(GeneralApplicationException))
+ {
+ throw e.Exception;
+ }
throw new GeneralApplicationException(e.ErrorInformation, e.Exception.Message, e.Exception);
}
diff --git a/win/CS/HandBrakeCS.csproj b/win/CS/HandBrakeCS.csproj
index 9bec51e55..117881d89 100644
--- a/win/CS/HandBrakeCS.csproj
+++ b/win/CS/HandBrakeCS.csproj
@@ -22,6 +22,7 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<SignManifests>false</SignManifests>
+ <TargetFrameworkProfile>Client</TargetFrameworkProfile>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
@@ -36,7 +37,6 @@
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
- <TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
@@ -48,7 +48,8 @@
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<UseVSHostingProcess>false</UseVSHostingProcess>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <DefineConstants>
+ </DefineConstants>
<Optimize>true</Optimize>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
diff --git a/win/CS/Program.cs b/win/CS/Program.cs
index 9939bfa42..fca7b0217 100644
--- a/win/CS/Program.cs
+++ b/win/CS/Program.cs
@@ -35,6 +35,7 @@ namespace Handbrake
// Handle any unhandled exceptions
AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;
+ Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);
// Check that HandBrakeCLI is availabl.
string failedInstall = "HandBrake is not installed properly. Please reinstall HandBrake. \n\n";
diff --git a/win/CS/frmMain.Designer.cs b/win/CS/frmMain.Designer.cs
index a53663b4d..8f1345b51 100644
--- a/win/CS/frmMain.Designer.cs
+++ b/win/CS/frmMain.Designer.cs
@@ -416,7 +416,7 @@ namespace Handbrake
this.ChaptersMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnu_resetChapters});
this.ChaptersMenu.Name = "presets_menu";
- this.ChaptersMenu.OwnerItem = this.btn_file_source;
+ this.ChaptersMenu.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
this.ChaptersMenu.Size = new System.Drawing.Size(188, 26);
this.ChaptersMenu.Text = ";";
//