From 0fd23ff799cf6d843ec34d40aba0a830260853b1 Mon Sep 17 00:00:00 2001 From: sr55 Date: Wed, 22 Aug 2007 15:29:49 +0000 Subject: [PATCH] WinGui: - Added debuging / crash prevention code in frmReadDVD. - Fixed issue with queue when adding items after initial encode. git-svn-id: svn://localhost/HandBrake/trunk@849 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Parsing/DVD.cs | 1 + win/C#/frmQueue.cs | 1 - win/C#/frmReadDVD.cs | 103 +++++++++++++++++++++++++++++++------------------- 3 files changed, 66 insertions(+), 39 deletions(-) diff --git a/win/C#/Parsing/DVD.cs b/win/C#/Parsing/DVD.cs index 02596124..3ba21202 100644 --- a/win/C#/Parsing/DVD.cs +++ b/win/C#/Parsing/DVD.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text; using System.IO; using System.Text.RegularExpressions; +using System.Windows.Forms; namespace Handbrake.Parsing { diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs index ee6301ae..62e32d37 100644 --- a/win/C#/frmQueue.cs +++ b/win/C#/frmQueue.cs @@ -55,7 +55,6 @@ namespace Handbrake if ((initialListCount - i) != (list_queue.Items.Count)) { - MessageBox.Show("Added an Item"); initialListCount++; } } diff --git a/win/C#/frmReadDVD.cs b/win/C#/frmReadDVD.cs index d56f0f33..ca6d2334 100644 --- a/win/C#/frmReadDVD.cs +++ b/win/C#/frmReadDVD.cs @@ -32,30 +32,45 @@ namespace Handbrake private void btn_ok_Click(object sender, EventArgs e) { - btn_ok.Enabled = false; - //btn_skip.Visible = true; - lbl_pressOk.Visible = false; - lbl_progress.Text = "0%"; - //lbl_progress.Visible = true; - lbl_status.Visible = true; - // throw cli call and parsing on it's own thread - ThreadPool.QueueUserWorkItem(startProc); + + try + { + btn_ok.Enabled = false; + //btn_skip.Visible = true; + lbl_pressOk.Visible = false; + lbl_progress.Text = "0%"; + //lbl_progress.Visible = true; + lbl_status.Visible = true; + // throw cli call and parsing on it's own thread + ThreadPool.QueueUserWorkItem(startProc); + } + catch(Exception exc) + { + MessageBox.Show(exc.ToString()); + } } private void updateUIElements() { - if (this.InvokeRequired) + try { - this.BeginInvoke(new UpdateUIHandler(updateUIElements)); - return; + if (this.InvokeRequired) + { + this.BeginInvoke(new UpdateUIHandler(updateUIElements)); + return; + } + // Now pass this streamreader to frmMain so that it can be used there. + mainWindow.setStreamReader(thisDvd); + + mainWindow.drp_dvdtitle.Items.Clear(); + mainWindow.drp_dvdtitle.Items.AddRange(thisDvd.Titles.ToArray()); + + this.Close(); + } + catch(Exception exc) + { + MessageBox.Show(exc.ToString()); } - // Now pass this streamreader to frmMain so that it can be used there. - mainWindow.setStreamReader(thisDvd); - - mainWindow.drp_dvdtitle.Items.Clear(); - mainWindow.drp_dvdtitle.Items.AddRange(thisDvd.Titles.ToArray()); - - this.Close(); } Functions.CLI process = new Functions.CLI(); @@ -68,20 +83,27 @@ namespace Handbrake /* * Quick and Dirty hack to get around the stderr crashes of hbcli. Lets try feeding brians parser text straight from a text file. */ - string appPath = Application.StartupPath.ToString(); - appPath = appPath + "\\"; - string strCmdLine = "cmd /c " + '"' + '"' + appPath + "\\hbcli.exe" + '"' + " -i" + '"' + inputFile + '"' + " -t0 >" + '"'+ appPath + "\\dvdinfo.dat" + '"' + " 2>&1" + '"'; - Process hbproc = Process.Start("CMD.exe", strCmdLine); - hbproc.WaitForExit(); - - - StreamReader sr = new StreamReader(appPath + "dvdinfo.dat"); - - thisDvd = Parsing.DVD.Parse(sr); - - sr.Close(); - Console.ReadLine(); - updateUIElements(); + try + { + string appPath = Application.StartupPath.ToString(); + appPath = appPath + "\\"; + string strCmdLine = "cmd /c " + '"' + '"' + appPath + "\\hbcli.exe" + '"' + " -i" + '"' + inputFile + '"' + " -t0 >" + '"'+ appPath + "\\dvdinfo.dat" + '"' + " 2>&1" + '"'; + Process hbproc = Process.Start("CMD.exe", strCmdLine); + hbproc.WaitForExit(); + + + StreamReader sr = new StreamReader(appPath + "dvdinfo.dat"); + + thisDvd = Parsing.DVD.Parse(sr); + + sr.Close(); + Console.ReadLine(); + updateUIElements(); + } + catch (Exception exc) + { + MessageBox.Show(exc.ToString()); + } //********************************************************************************************************************************************* /* @@ -105,7 +127,7 @@ namespace Handbrake */ } - private void Parser_OnScanProgress(object Sender, int CurrentTitle, int TitleCount) + /*private void Parser_OnScanProgress(object Sender, int CurrentTitle, int TitleCount) { if (this.InvokeRequired) { @@ -118,14 +140,19 @@ namespace Handbrake progress = 100; } this.lbl_progress.Text = progress.ToString() + "%"; - } + }*/ private void btn_skip_Click(object sender, EventArgs e) { - //process.killCLI(); - this.Close(); - cancel = 1; + try + { + this.Close(); + cancel = 1; + } + catch (Exception exc) + { + MessageBox.Show(exc.ToString()); + } } - } } \ No newline at end of file -- 2.11.0