OSDN Git Service

# Changed
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 11 May 2009 12:49:29 +0000 (12:49 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 11 May 2009 12:49:29 +0000 (12:49 +0000)
- Initial work for multi-instance support. All CLI processes controled by their process ID, not Name. This prevents a scan from 1 instance killing a CLI encode from another.

# Fixed
- Disable angle dropdown when not using Libdvdnav
- Fixed issue with angle dropdown where first item is not selected. This caused the generate query to break due to "--angle" with no value.
- Fixed issue with the dropdown menu setup on the audio tab not working correctly due to updated encoder names and DTS support.
- Fixed an exception conditon on cancel scan.

git-svn-id: svn://localhost/HandBrake/trunk@2412 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/Functions/Encode.cs
win/C#/Functions/QueryGenerator.cs
win/C#/Presets/PresetsHandler.cs
win/C#/frmMain.Designer.cs
win/C#/frmMain.cs

index 870c24a..044fad3 100644 (file)
@@ -41,6 +41,7 @@ namespace Handbrake.Functions
                 if (Properties.Settings.Default.cli_minimized == "Checked")\r
                     cliStart.WindowStyle = ProcessWindowStyle.Minimized;\r
                 hbProc = Process.Start(cliStart);\r
+                processID = hbProc.Id;\r
                 isEncoding = true;\r
                 currentQuery = query;\r
 \r
@@ -137,40 +138,36 @@ namespace Handbrake.Functions
         /// <param name="destination"></param>\r
         public void copyLog(string destination)\r
         {\r
-            // The user may wish to do something with the log.\r
-            if (Properties.Settings.Default.saveLogToSpecifiedPath == "Checked")\r
+            try\r
             {\r
-                try\r
-                {\r
-                    string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
-                    string tempLogFile = Path.Combine(logDir, "last_encode_log.txt");\r
-\r
-                    string encodeDestinationPath = Path.GetDirectoryName(destination);\r
-                    String[] destName = destination.Split('\\');\r
-                    string destinationFile = destName[destName.Length - 1];\r
-                    string encodeLogFile = DateTime.Now.ToString().Replace("/", "-").Replace(":", "-") + " " + destinationFile + ".txt";\r
-\r
-                    // Make sure the log directory exists.\r
-                    if (!Directory.Exists(logDir))\r
-                        Directory.CreateDirectory(logDir);\r
-\r
-                    // Copy the Log to HandBrakes log folder in the users applciation data folder.\r
-                    File.Copy(tempLogFile, Path.Combine(logDir, encodeLogFile));\r
-\r
-                    // Save a copy of the log file in the same location as the enocde.\r
-                    if (Properties.Settings.Default.saveLogWithVideo == "Checked")\r
-                        File.Copy(tempLogFile, Path.Combine(encodeDestinationPath, encodeLogFile));\r
-\r
-                    // Save a copy of the log file to a user specified location\r
-                    if (Directory.Exists(Properties.Settings.Default.saveLogPath))\r
-                        if (Properties.Settings.Default.saveLogPath != String.Empty && Properties.Settings.Default.saveLogToSpecifiedPath == "Checked")\r
-                            File.Copy(tempLogFile, Path.Combine(Properties.Settings.Default.saveLogPath, encodeLogFile));\r
-                }\r
-                catch (Exception exc)\r
-                {\r
-                    MessageBox.Show("Something went a bit wrong trying to copy your log file.\nError Information:\n\n" + exc, "Error",\r
-                                    MessageBoxButtons.OK, MessageBoxIcon.Error);\r
-                }\r
+                string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
+                string tempLogFile = Path.Combine(logDir, "last_encode_log.txt");\r
+\r
+                string encodeDestinationPath = Path.GetDirectoryName(destination);\r
+                String[] destName = destination.Split('\\');\r
+                string destinationFile = destName[destName.Length - 1];\r
+                string encodeLogFile = DateTime.Now.ToString().Replace("/", "-").Replace(":", "-") + " " + destinationFile + ".txt";\r
+\r
+                // Make sure the log directory exists.\r
+                if (!Directory.Exists(logDir))\r
+                    Directory.CreateDirectory(logDir);\r
+\r
+                // Copy the Log to HandBrakes log folder in the users applciation data folder.\r
+                File.Copy(tempLogFile, Path.Combine(logDir, encodeLogFile));\r
+\r
+                // Save a copy of the log file in the same location as the enocde.\r
+                if (Properties.Settings.Default.saveLogWithVideo == "Checked")\r
+                    File.Copy(tempLogFile, Path.Combine(encodeDestinationPath, encodeLogFile));\r
+\r
+                // Save a copy of the log file to a user specified location\r
+                if (Directory.Exists(Properties.Settings.Default.saveLogPath))\r
+                    if (Properties.Settings.Default.saveLogPath != String.Empty && Properties.Settings.Default.saveLogToSpecifiedPath == "Checked")\r
+                        File.Copy(tempLogFile, Path.Combine(Properties.Settings.Default.saveLogPath, encodeLogFile));\r
+            }\r
+            catch (Exception exc)\r
+            {\r
+                MessageBox.Show("Something went a bit wrong trying to copy your log file.\nError Information:\n\n" + exc, "Error",\r
+                                MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
         }\r
 \r
@@ -184,5 +181,10 @@ namespace Handbrake.Functions
         /// </summary>\r
         public String currentQuery { get; set; }\r
 \r
+        /// <summary>\r
+        /// Get the process ID of the current encode.\r
+        /// </summary>\r
+        public int processID { get; set; }\r
+\r
     }\r
 }\r
index f2a083a..e043d85 100644 (file)
@@ -34,8 +34,9 @@ namespace Handbrake.Functions
                 query += " -t " + titleInfo[0];\r
             }\r
 \r
-            if (mainWindow.drop_angle.SelectedIndex != 0)\r
-                query += " --angle " + mainWindow.drop_angle.SelectedItem;\r
+            if (Properties.Settings.Default.dvdnav == "Checked")\r
+                if (mainWindow.drop_angle.Items.Count != 0)\r
+                    query += " --angle " + mainWindow.drop_angle.SelectedItem;\r
 \r
             if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "Auto")\r
                 query += " -c " + mainWindow.drop_chapterStart.Text;\r
index 2ba6acc..4132945 100644 (file)
@@ -384,6 +384,11 @@ namespace Handbrake.Presets
             return false;\r
         }\r
 \r
+        /// <summary>\r
+        /// Check if the built in presets stored are not out of date.\r
+        /// Update them if they are.\r
+        /// </summary>\r
+        /// <returns></returns>\r
         public Boolean checkIfPresetsAreOutOfDate()\r
         {\r
             loadPresetData();\r
index 6cab7ba..a732cf2 100644 (file)
@@ -110,7 +110,7 @@ namespace Handbrake
             this.debugToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();\r
             this.mnu_qptest = new System.Windows.Forms.ToolStripMenuItem();\r
             this.gb_source = new System.Windows.Forms.GroupBox();\r
-            this.label4 = new System.Windows.Forms.Label();\r
+            this.lbl_angle = new System.Windows.Forms.Label();\r
             this.Label13 = new System.Windows.Forms.Label();\r
             this.Label17 = new System.Windows.Forms.Label();\r
             this.Label9 = new System.Windows.Forms.Label();\r
@@ -183,14 +183,9 @@ namespace Handbrake
             this.Check_ChapterMarkers = new System.Windows.Forms.CheckBox();\r
             this.tabs_panel = new System.Windows.Forms.TabControl();\r
             this.tab_Filters = new System.Windows.Forms.TabPage();\r
-            this.ctl_deinterlace = new Handbrake.Deinterlace();\r
-            this.ctl_denoise = new Handbrake.Denoise();\r
-            this.ctl_decomb = new Handbrake.Decomb();\r
-            this.ctl_detelecine = new Handbrake.Detelecine();\r
             this.tab_chapters = new System.Windows.Forms.TabPage();\r
             this.label31 = new System.Windows.Forms.Label();\r
             this.h264Tab = new System.Windows.Forms.TabPage();\r
-            this.x264Panel = new Handbrake.Controls.x264Panel();\r
             this.tab_query = new System.Windows.Forms.TabPage();\r
             this.btn_clear = new System.Windows.Forms.Button();\r
             this.label34 = new System.Windows.Forms.Label();\r
@@ -225,6 +220,11 @@ namespace Handbrake
             this.StatusStrip = new System.Windows.Forms.StatusStrip();\r
             this.lbl_encode = new System.Windows.Forms.ToolStripStatusLabel();\r
             this.hbproc = new System.Diagnostics.Process();\r
+            this.ctl_deinterlace = new Handbrake.Deinterlace();\r
+            this.ctl_denoise = new Handbrake.Denoise();\r
+            this.ctl_decomb = new Handbrake.Decomb();\r
+            this.ctl_detelecine = new Handbrake.Detelecine();\r
+            this.x264Panel = new Handbrake.Controls.x264Panel();\r
             notifyIconMenu = new System.Windows.Forms.ContextMenuStrip(this.components);\r
             notifyIconMenu.SuspendLayout();\r
             ((System.ComponentModel.ISupportInitialize)(this.slider_videoQuality)).BeginInit();\r
@@ -716,13 +716,13 @@ namespace Handbrake
             // \r
             // drop_angle\r
             // \r
+            this.drop_angle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
             this.drop_angle.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
             this.drop_angle.FormattingEnabled = true;\r
             this.drop_angle.Location = new System.Drawing.Point(250, 52);\r
             this.drop_angle.Name = "drop_angle";\r
             this.drop_angle.Size = new System.Drawing.Size(45, 21);\r
             this.drop_angle.TabIndex = 45;\r
-            this.drop_angle.Text = "1";\r
             this.ToolTip.SetToolTip(this.drop_angle, "Select the chapter range you would like to enocde. (default: All Chapters)");\r
             // \r
             // lbl_src_res\r
@@ -998,7 +998,7 @@ namespace Handbrake
             // gb_source\r
             // \r
             this.gb_source.Controls.Add(this.drop_angle);\r
-            this.gb_source.Controls.Add(this.label4);\r
+            this.gb_source.Controls.Add(this.lbl_angle);\r
             this.gb_source.Controls.Add(this.lbl_duration);\r
             this.gb_source.Controls.Add(this.label_duration);\r
             this.gb_source.Controls.Add(this.Label13);\r
@@ -1018,16 +1018,16 @@ namespace Handbrake
             this.gb_source.TabStop = false;\r
             this.gb_source.Text = "Source";\r
             // \r
-            // label4\r
+            // lbl_angle\r
             // \r
-            this.label4.AutoSize = true;\r
-            this.label4.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.label4.ForeColor = System.Drawing.Color.Black;\r
-            this.label4.Location = new System.Drawing.Point(200, 55);\r
-            this.label4.Name = "label4";\r
-            this.label4.Size = new System.Drawing.Size(44, 13);\r
-            this.label4.TabIndex = 44;\r
-            this.label4.Text = "Angle:";\r
+            this.lbl_angle.AutoSize = true;\r
+            this.lbl_angle.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.lbl_angle.ForeColor = System.Drawing.Color.Black;\r
+            this.lbl_angle.Location = new System.Drawing.Point(200, 55);\r
+            this.lbl_angle.Name = "lbl_angle";\r
+            this.lbl_angle.Size = new System.Drawing.Size(44, 13);\r
+            this.lbl_angle.TabIndex = 44;\r
+            this.lbl_angle.Text = "Angle:";\r
             // \r
             // Label13\r
             // \r
@@ -1877,48 +1877,6 @@ namespace Handbrake
             this.tab_Filters.Text = "Video Filters";\r
             this.tab_Filters.UseVisualStyleBackColor = true;\r
             // \r
-            // ctl_deinterlace\r
-            // \r
-            this.ctl_deinterlace.AutoSize = true;\r
-            this.ctl_deinterlace.Location = new System.Drawing.Point(19, 95);\r
-            this.ctl_deinterlace.Margin = new System.Windows.Forms.Padding(0);\r
-            this.ctl_deinterlace.MaximumSize = new System.Drawing.Size(400, 30);\r
-            this.ctl_deinterlace.Name = "ctl_deinterlace";\r
-            this.ctl_deinterlace.Size = new System.Drawing.Size(275, 28);\r
-            this.ctl_deinterlace.TabIndex = 41;\r
-            this.ctl_deinterlace.onChange += new System.EventHandler(this.ctl_deinterlace_changed);\r
-            // \r
-            // ctl_denoise\r
-            // \r
-            this.ctl_denoise.AutoSize = true;\r
-            this.ctl_denoise.Location = new System.Drawing.Point(19, 123);\r
-            this.ctl_denoise.Margin = new System.Windows.Forms.Padding(0);\r
-            this.ctl_denoise.MaximumSize = new System.Drawing.Size(400, 30);\r
-            this.ctl_denoise.Name = "ctl_denoise";\r
-            this.ctl_denoise.Size = new System.Drawing.Size(275, 28);\r
-            this.ctl_denoise.TabIndex = 40;\r
-            // \r
-            // ctl_decomb\r
-            // \r
-            this.ctl_decomb.AutoSize = true;\r
-            this.ctl_decomb.Location = new System.Drawing.Point(19, 66);\r
-            this.ctl_decomb.Margin = new System.Windows.Forms.Padding(0);\r
-            this.ctl_decomb.MaximumSize = new System.Drawing.Size(400, 30);\r
-            this.ctl_decomb.Name = "ctl_decomb";\r
-            this.ctl_decomb.Size = new System.Drawing.Size(275, 28);\r
-            this.ctl_decomb.TabIndex = 39;\r
-            this.ctl_decomb.onChange += new System.EventHandler(this.ctl_decomb_changed);\r
-            // \r
-            // ctl_detelecine\r
-            // \r
-            this.ctl_detelecine.AutoSize = true;\r
-            this.ctl_detelecine.Location = new System.Drawing.Point(19, 38);\r
-            this.ctl_detelecine.Margin = new System.Windows.Forms.Padding(0);\r
-            this.ctl_detelecine.MaximumSize = new System.Drawing.Size(400, 30);\r
-            this.ctl_detelecine.Name = "ctl_detelecine";\r
-            this.ctl_detelecine.Size = new System.Drawing.Size(275, 28);\r
-            this.ctl_detelecine.TabIndex = 38;\r
-            // \r
             // tab_chapters\r
             // \r
             this.tab_chapters.BackColor = System.Drawing.Color.Transparent;\r
@@ -1956,14 +1914,6 @@ namespace Handbrake
             this.h264Tab.Text = "Advanced";\r
             this.h264Tab.UseVisualStyleBackColor = true;\r
             // \r
-            // x264Panel\r
-            // \r
-            this.x264Panel.Location = new System.Drawing.Point(0, 0);\r
-            this.x264Panel.Name = "x264Panel";\r
-            this.x264Panel.Size = new System.Drawing.Size(720, 306);\r
-            this.x264Panel.TabIndex = 0;\r
-            this.x264Panel.x264Query = "";\r
-            // \r
             // tab_query\r
             // \r
             this.tab_query.Controls.Add(this.btn_clear);\r
@@ -2323,6 +2273,56 @@ namespace Handbrake
             this.hbproc.StartInfo.UserName = "";\r
             this.hbproc.SynchronizingObject = this;\r
             // \r
+            // ctl_deinterlace\r
+            // \r
+            this.ctl_deinterlace.AutoSize = true;\r
+            this.ctl_deinterlace.Location = new System.Drawing.Point(19, 95);\r
+            this.ctl_deinterlace.Margin = new System.Windows.Forms.Padding(0);\r
+            this.ctl_deinterlace.MaximumSize = new System.Drawing.Size(400, 30);\r
+            this.ctl_deinterlace.Name = "ctl_deinterlace";\r
+            this.ctl_deinterlace.Size = new System.Drawing.Size(275, 28);\r
+            this.ctl_deinterlace.TabIndex = 41;\r
+            this.ctl_deinterlace.onChange += new System.EventHandler(this.ctl_deinterlace_changed);\r
+            // \r
+            // ctl_denoise\r
+            // \r
+            this.ctl_denoise.AutoSize = true;\r
+            this.ctl_denoise.Location = new System.Drawing.Point(19, 123);\r
+            this.ctl_denoise.Margin = new System.Windows.Forms.Padding(0);\r
+            this.ctl_denoise.MaximumSize = new System.Drawing.Size(400, 30);\r
+            this.ctl_denoise.Name = "ctl_denoise";\r
+            this.ctl_denoise.Size = new System.Drawing.Size(275, 28);\r
+            this.ctl_denoise.TabIndex = 40;\r
+            // \r
+            // ctl_decomb\r
+            // \r
+            this.ctl_decomb.AutoSize = true;\r
+            this.ctl_decomb.Location = new System.Drawing.Point(19, 66);\r
+            this.ctl_decomb.Margin = new System.Windows.Forms.Padding(0);\r
+            this.ctl_decomb.MaximumSize = new System.Drawing.Size(400, 30);\r
+            this.ctl_decomb.Name = "ctl_decomb";\r
+            this.ctl_decomb.Size = new System.Drawing.Size(275, 28);\r
+            this.ctl_decomb.TabIndex = 39;\r
+            this.ctl_decomb.onChange += new System.EventHandler(this.ctl_decomb_changed);\r
+            // \r
+            // ctl_detelecine\r
+            // \r
+            this.ctl_detelecine.AutoSize = true;\r
+            this.ctl_detelecine.Location = new System.Drawing.Point(19, 38);\r
+            this.ctl_detelecine.Margin = new System.Windows.Forms.Padding(0);\r
+            this.ctl_detelecine.MaximumSize = new System.Drawing.Size(400, 30);\r
+            this.ctl_detelecine.Name = "ctl_detelecine";\r
+            this.ctl_detelecine.Size = new System.Drawing.Size(275, 28);\r
+            this.ctl_detelecine.TabIndex = 38;\r
+            // \r
+            // x264Panel\r
+            // \r
+            this.x264Panel.Location = new System.Drawing.Point(0, 0);\r
+            this.x264Panel.Name = "x264Panel";\r
+            this.x264Panel.Size = new System.Drawing.Size(720, 306);\r
+            this.x264Panel.TabIndex = 0;\r
+            this.x264Panel.x264Query = "";\r
+            // \r
             // frmMain\r
             // \r
             this.AllowDrop = true;\r
@@ -2574,7 +2574,7 @@ namespace Handbrake
         internal TextBox text_source;\r
         private System.Diagnostics.Process hbproc;\r
         internal ComboBox drop_angle;\r
-        internal Label label4;\r
+        internal Label lbl_angle;\r
 \r
  \r
     }\r
index a8c7a8a..edea6c5 100644 (file)
@@ -36,7 +36,7 @@ namespace Handbrake
 \r
         // Delegates\r
         private delegate void UpdateWindowHandler();\r
-        private delegate void updateStatusChanger();\r
+        private delegate void UpdateStatusChanger();\r
 \r
         // Applicaiton Startup ************************************************\r
 \r
@@ -133,7 +133,7 @@ namespace Handbrake
             {\r
                 if (InvokeRequired)\r
                 {\r
-                    BeginInvoke(new updateStatusChanger(startupUpdateCheck));\r
+                    BeginInvoke(new UpdateStatusChanger(startupUpdateCheck));\r
                     return;\r
                 }\r
 \r
@@ -230,7 +230,7 @@ namespace Handbrake
         #region File Menu\r
         private void mnu_killCLI_Click(object sender, EventArgs e)\r
         {\r
-            killCLI();\r
+            killScan();\r
         }\r
         private void mnu_exit_Click(object sender, EventArgs e)\r
         {\r
@@ -847,7 +847,19 @@ namespace Handbrake
 \r
                 // Populate the Angles dropdown\r
                 drop_angle.Items.Clear();\r
-                drop_angle.Items.AddRange(selectedTitle.Angles.ToArray());\r
+                if (Properties.Settings.Default.dvdnav == "Checked")\r
+                {\r
+                    drop_angle.Visible = true;\r
+                    lbl_angle.Visible = true;\r
+                    drop_angle.Items.AddRange(selectedTitle.Angles.ToArray());\r
+                    if (drop_angle.Items.Count != 0)\r
+                        drop_angle.SelectedIndex = 0;\r
+                }\r
+                else\r
+                {\r
+                    drop_angle.Visible = false;\r
+                    lbl_angle.Visible = false;\r
+                }\r
 \r
                 // Populate the Start chapter Dropdown\r
                 drop_chapterStart.Items.Clear();\r
@@ -1363,7 +1375,7 @@ namespace Handbrake
         }\r
         private void drp_audenc_1_SelectedIndexChanged(object sender, EventArgs e)\r
         {\r
-            if (drp_audenc_1.Text == "AC3" || drp_audenc_1.Text == "DTS")\r
+            if (drp_audenc_1.Text.Contains("AC3") || drp_audenc_1.Text.Contains("DTS"))\r
             {\r
                 drp_audmix_1.Enabled = false;\r
                 drp_audbit_1.Enabled = false;\r
@@ -1384,7 +1396,7 @@ namespace Handbrake
                 drp_audsr_1.Text = "Auto";\r
             }\r
 \r
-            if (drp_audenc_1.Text == "AAC")\r
+            if (drp_audenc_1.Text.Contains("AAC"))\r
             {\r
                 setMixDownAllOptions(drp_audmix_1);\r
                 setBitrateSelections160(drp_audbit_1);\r
@@ -1404,9 +1416,9 @@ namespace Handbrake
         }\r
         private void drp_audmix_1_SelectedIndexChanged(object sender, EventArgs e)\r
         {\r
-            if ((drp_audenc_1.Text == "AAC") && (drp_audmix_1.Text == "6 Channel Discrete"))\r
+            if ((drp_audenc_1.Text.Contains("AAC")) && (drp_audmix_1.Text == "6 Channel Discrete"))\r
                 setBitrateSelections384(drp_audbit_1);\r
-            else if ((drp_audenc_1.Text == "AAC") && (drp_audmix_1.Text != "6 Channel Discrete"))\r
+            else if ((drp_audenc_1.Text.Contains("AAC")) && (drp_audmix_1.Text != "6 Channel Discrete"))\r
                 setBitrateSelections160(drp_audbit_1); drp_audbit_1.Text = "160";\r
 \r
             // Update an item in the Audio list if required.\r
@@ -1430,7 +1442,7 @@ namespace Handbrake
             // Update an item in the Audio list if required.\r
             if (lv_audioList.Items.Count != 0 && lv_audioList.SelectedIndices.Count != 0)\r
             {\r
-                if (drp_audenc_1.Text == "AC3")\r
+                if (drp_audenc_1.Text.Contains("AC3"))\r
                     drp_audbit_1.Text = "Auto";\r
                 lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[4].Text = drp_audbit_1.Text;\r
                 lv_audioList.Select();\r
@@ -1598,6 +1610,7 @@ namespace Handbrake
         // MainWindow Components, Actions and Functions ***********************\r
 \r
         #region Source Scan\r
+        private static int scanProcessID { get; set; }\r
         private void setupGUIforScan(String filename)\r
         {\r
             text_source.Text = filename;\r
@@ -1650,24 +1663,33 @@ namespace Handbrake
 \r
                 ProcessStartInfo hbParseDvd = new ProcessStartInfo("CMD.exe", strCmdLine) { WindowStyle = ProcessWindowStyle.Hidden };\r
 \r
+                Boolean cleanExit = true;\r
                 using (hbproc = Process.Start(hbParseDvd))\r
                 {\r
+                    scanProcessID = hbproc.Id;\r
                     hbproc.WaitForExit();\r
+                    if (hbproc.ExitCode != 0)\r
+                        cleanExit = false;\r
                 }\r
 \r
-                if (!File.Exists(dvdInfoPath))\r
+                if (cleanExit) // If 0 exit code, CLI exited cleanly.\r
                 {\r
-                    throw new Exception("Unable to retrieve the DVD Info. last_scan_log.txt is missing. \nExpected location of last_scan_log.txt: \n" + dvdInfoPath);\r
-                }\r
+                    if (!File.Exists(dvdInfoPath))\r
+                    {\r
+                        throw new Exception(\r
+                            "Unable to retrieve the DVD Info. last_scan_log.txt is missing. \nExpected location of last_scan_log.txt: \n" +\r
+                            dvdInfoPath);\r
+                    }\r
 \r
-                using (StreamReader sr = new StreamReader(dvdInfoPath))\r
-                {\r
-                    thisDVD = DVD.Parse(sr);\r
-                    sr.Close();\r
-                    sr.Dispose();\r
-                }\r
+                    using (StreamReader sr = new StreamReader(dvdInfoPath))\r
+                    {\r
+                        thisDVD = DVD.Parse(sr);\r
+                        sr.Close();\r
+                        sr.Dispose();\r
+                    }\r
 \r
-                updateUIafterScan();\r
+                    updateUIafterScan();\r
+                }\r
             }\r
             catch (Exception exc)\r
             {\r
@@ -1725,9 +1747,7 @@ namespace Handbrake
             try\r
             {\r
                 if (InvokeRequired)\r
-                {\r
-                    BeginInvoke(new UpdateWindowHandler(updateUIafterScan));\r
-                }\r
+                    BeginInvoke(new UpdateWindowHandler(enableGUI));\r
                 lbl_encode.Text = "Scan Completed";\r
                 gb_source.Text = "Source";\r
                 foreach (Control ctrl in Controls)\r
@@ -1741,27 +1761,24 @@ namespace Handbrake
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show("frmMain.cs - enableGUI " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                MessageBox.Show("frmMain.cs - enableGUI() " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
         }\r
-        private static void killCLI()\r
+        private void killScan()\r
         {\r
-            // This may seem like a long way of killing HandBrakeCLI, but for whatever reason,\r
-            // hbproc.kill/close just won't do the trick.\r
             try\r
             {\r
-                string AppName = "HandBrakeCLI";\r
-\r
-                AppName = AppName.ToUpper();\r
-\r
+                enableGUI();\r
+                resetGUI();\r
+                \r
                 Process[] prs = Process.GetProcesses();\r
-                foreach (Process proces in prs)\r
+                foreach (Process process in prs)\r
                 {\r
-                    if (proces.ProcessName.ToUpper() == AppName)\r
+                    if (process.Id == scanProcessID)\r
                     {\r
-                        proces.Refresh();\r
-                        if (!proces.HasExited)\r
-                            proces.Kill();\r
+                        process.Refresh();\r
+                        if (!process.HasExited)\r
+                            process.Kill();\r
                     }\r
                 }\r
             }\r
@@ -1770,6 +1787,22 @@ namespace Handbrake
                 MessageBox.Show("Unable to kill HandBrakeCLI.exe \nYou may need to manually kill HandBrakeCLI.exe using the Windows Task Manager if it does not close automatically within the next few minutes. \n\nError Information: \n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
             }\r
         }\r
+        private void resetGUI()\r
+        {\r
+            drp_dvdtitle.Items.Clear();\r
+            drp_dvdtitle.Text = "Automatic";\r
+            drop_chapterStart.Items.Clear();\r
+            drop_chapterStart.Text = "Auto";\r
+            drop_chapterFinish.Items.Clear();\r
+            drop_chapterFinish.Text = "Auto";\r
+            lbl_duration.Text = "Select a Title";\r
+            lbl_src_res.Text = "Select a Title";\r
+            lbl_Aspect.Text = "Select a Title";\r
+            text_source.Text = "Click 'Source' to continue";\r
+            text_destination.Text = "";\r
+            thisDVD = null;\r
+            selectedTitle = null;\r
+        }\r
         #endregion\r
 \r
         #region GUI\r
@@ -1876,7 +1909,7 @@ namespace Handbrake
                 drp_audenc_1.Items.Clear();\r
                 drp_audenc_1.Items.Add("AAC (faac)");\r
                 drp_audenc_1.Items.Add("AC3 Passthru");\r
-                if ((oldval != "AAC") && (oldval != "AC3"))\r
+                if ((oldval != "AAC (faac)") && (oldval != "AC3 Passthru"))\r
                     drp_audenc_1.SelectedIndex = 0;\r
 \r
             }\r