diff options
author | sr55 <[email protected]> | 2008-08-16 19:42:44 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2008-08-16 19:42:44 +0000 |
commit | fa9459cd2bd333541564d08a3bfc7d0edf44443b (patch) | |
tree | dabba69dfbc834befb4ce662e40a9805ec5a51d3 /win/C#/frmReadDVD.cs | |
parent | 0d63c1bef741e359f8d10664266ad4c6b411cd6c (diff) |
WinGui:
- One elusive cross-thread bug in the Activity window fix (hopefully) + some tweaks to the log display
- Nicer Exception Handling Message box errors for frmReadDVD.
- frmMain Minimize to taskbar no tooltip text exception fixed.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1634 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/frmReadDVD.cs')
-rw-r--r-- | win/C#/frmReadDVD.cs | 89 |
1 files changed, 51 insertions, 38 deletions
diff --git a/win/C#/frmReadDVD.cs b/win/C#/frmReadDVD.cs index 3eb212d4f..21dfa6505 100644 --- a/win/C#/frmReadDVD.cs +++ b/win/C#/frmReadDVD.cs @@ -27,6 +27,7 @@ namespace Handbrake private delegate void UpdateUIHandler();
Process hbproc;
Functions.Common hb_common_func = new Functions.Common();
+ Functions.Encode process = new Functions.Encode();
public frmReadDVD(string inputFile, frmMain parent)
{
@@ -45,10 +46,51 @@ namespace Handbrake }
catch (Exception exc)
{
- MessageBox.Show("frmReadDVD.cs - startScan " + exc.ToString());
+ MessageBox.Show("frmReadDVD.cs - startScan " + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
+ private void startProc(object state)
+ {
+ try
+ {
+ string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");
+ string dvdInfoPath = Path.Combine(Path.GetTempPath(), "dvdinfo.dat");
+
+ // Make we don't pick up a stale hb_encode_log.dat (and that we have rights to the file)
+ if (File.Exists(dvdInfoPath))
+ File.Delete(dvdInfoPath);
+
+ string strCmdLine = String.Format(@"cmd /c """"{0}"" -i ""{1}"" -t0 -v >""{2}"" 2>&1""", handbrakeCLIPath, inputFile, dvdInfoPath);
+
+ ProcessStartInfo hbParseDvd = new ProcessStartInfo("CMD.exe", strCmdLine);
+ hbParseDvd.WindowStyle = ProcessWindowStyle.Hidden;
+
+ using (hbproc = Process.Start(hbParseDvd))
+ {
+ hbproc.WaitForExit();
+ }
+
+ if (!File.Exists(dvdInfoPath))
+ {
+ throw new Exception("Unable to retrieve the DVD Info. dvdinfo.dat is missing. \nExpected location of dvdinfo.dat: \n" + dvdInfoPath);
+ }
+
+ using (StreamReader sr = new StreamReader(dvdInfoPath))
+ {
+ thisDvd = Parsing.DVD.Parse(sr);
+ sr.Close();
+ sr.Dispose();
+ }
+
+ updateUIElements();
+ }
+ catch (Exception exc)
+ {
+ MessageBox.Show("frmReadDVD.cs - startProc() " + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ closeWindowAfterError();
+ }
+ }
private void updateUIElements()
{
try
@@ -76,54 +118,25 @@ namespace Handbrake }
catch (Exception exc)
{
- MessageBox.Show("frmReadDVD.cs - updateUIElements " + exc.ToString());
+ MessageBox.Show("frmReadDVD.cs - updateUIElements " + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close();
}
}
-
- Functions.Encode process = new Functions.Encode();
-
- private void startProc(object state)
+ private void closeWindowAfterError()
{
try
{
- string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");
- string dvdInfoPath = Path.Combine(Path.GetTempPath(), "dvdinfo.dat");
-
- // Make we don't pick up a stale hb_encode_log.dat (and that we have rights to the file)
- if (File.Exists(dvdInfoPath))
- File.Delete(dvdInfoPath);
-
- string strCmdLine = String.Format(@"cmd /c """"{0}"" -i ""{1}"" -t0 -v >""{2}"" 2>&1""", handbrakeCLIPath, inputFile, dvdInfoPath);
-
- ProcessStartInfo hbParseDvd = new ProcessStartInfo("CMD.exe", strCmdLine);
- hbParseDvd.WindowStyle = ProcessWindowStyle.Hidden;
-
- using (hbproc = Process.Start(hbParseDvd))
- {
- hbproc.WaitForExit();
- }
-
- if (!File.Exists(dvdInfoPath))
- {
- throw new Exception("Unable to retrieve the DVD Info. dvdinfo.dat is missing.");
- }
-
- using (StreamReader sr = new StreamReader(dvdInfoPath))
+ if (this.InvokeRequired)
{
- thisDvd = Parsing.DVD.Parse(sr);
- sr.Close();
- sr.Dispose();
+ this.BeginInvoke(new UpdateUIHandler(closeWindowAfterError));
+ return;
}
-
- updateUIElements();
+ this.Close();
}
catch (Exception exc)
{
- MessageBox.Show("frmReadDVD.cs - startProc " + exc.ToString());
- this.Close();
+ MessageBox.Show("frmReadDVD.cs - closeWindowAfterError - Unable to recover from a serious error. \n\n Error Information: \n " + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
-
}
private void btn_cancel_Click(object sender, EventArgs e)
@@ -149,7 +162,7 @@ namespace Handbrake }
catch (Exception ex)
{
- MessageBox.Show(ex.Message);
+ MessageBox.Show("Unable to kill HandBrakeCLI.exe \n\nError Information: \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
|