OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 15 Jul 2010 20:15:08 +0000 (20:15 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 15 Jul 2010 20:15:08 +0000 (20:15 +0000)
- Multiple instance support.
  Each instance has a unique id. id = 0 will use the standard log/queue files.
  id = 1,2...n will use standard file names but with the instance id added to the end.
  This means that each instance will have it's own queue. Queue is not shared between Instances
  If multiple queue files are found when starting up, it will offer to load them all in.

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

win/C#/Functions/Main.cs
win/C#/HandBrake.ApplicationServices/Init.cs
win/C#/HandBrake.ApplicationServices/Services/Encode.cs
win/C#/HandBrake.ApplicationServices/Services/Queue.cs
win/C#/HandBrake.ApplicationServices/Services/Scan.cs
win/C#/Program.cs
win/C#/frmMain.cs
win/C#/frmOptions.cs

index 2bf6e6f..15714ee 100644 (file)
@@ -372,77 +372,51 @@ namespace Handbrake.Functions
         /// <returns>\r
         /// True if there is a queue to recover.\r
         /// </returns>\r
-        public static bool CheckQueueRecovery()\r
+        public static List<string> CheckQueueRecovery()\r
         {\r
             try\r
             {\r
-                string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\hb_queue_recovery.xml");\r
-                if (File.Exists(tempPath))\r
+                string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");\r
+                List<string> queueFiles = new List<string>();\r
+\r
+                DirectoryInfo info = new DirectoryInfo(tempPath);\r
+                FileInfo[] logFiles = info.GetFiles("*.xml");\r
+                foreach (FileInfo file in logFiles)\r
                 {\r
-                    using (FileStream strm = new FileStream(tempPath, FileMode.Open, FileAccess.Read))\r
+                    if (!file.Name.Contains("hb_queue_recovery"))\r
+                        continue;\r
+\r
+                    using (FileStream strm = new FileStream(Path.Combine(file.DirectoryName, file.Name), FileMode.Open, FileAccess.Read))\r
                     {\r
                         List<Job> list = Ser.Deserialize(strm) as List<Job>;\r
                         if (list != null)\r
+                        {\r
                             if (list.Count != 0)\r
-                                return true;\r
+                            {\r
+                                queueFiles.Add(file.Name);\r
+                            }\r
+                        }\r
                     }\r
                 }\r
-                return false;\r
+\r
+                return queueFiles;\r
             }\r
             catch (Exception)\r
             {\r
-                return false; // Keep quiet about the error.\r
+                return new List<string>(); // Keep quiet about the error.\r
             }\r
         }\r
 \r
         /// <summary>\r
-        /// Get the Process ID of HandBrakeCLI for the current instance.\r
+        /// Checks if this HandBrake is running multiple instances\r
         /// </summary>\r
-        /// <param name="before">List of processes before the new process was started</param>\r
-        /// <returns>Int - Process ID</returns>\r
-        public static int GetCliProcess(Process[] before)\r
+        /// <returns>True if the UI has another instance running</returns>\r
+        public static bool IsMultiInstance\r
         {\r
-            // This is a bit of a cludge. Maybe someone has a better idea on how to impliment this.\r
-            // Since we used CMD to start HandBrakeCLI, we don't get the process ID from hbProc.\r
-            // Instead we take the processes before and after, and get the ID of HandBrakeCLI.exe\r
-            // avoiding any previous instances of HandBrakeCLI.exe in before.\r
-            // Kill the current process.\r
-\r
-            DateTime startTime = DateTime.Now;\r
-            TimeSpan duration;\r
-\r
-            Process[] hbProcesses = Process.GetProcessesByName("HandBrakeCLI");\r
-            while (hbProcesses.Length == 0)\r
+            get\r
             {\r
-                hbProcesses = Process.GetProcessesByName("HandBrakeCLI");\r
-                duration = DateTime.Now - startTime;\r
-                if (duration.Seconds > 5 && hbProcesses.Length == 0)\r
-                    // Make sure we don't wait forever if the process doesn't start\r
-                    return -1;\r
+                return Process.GetProcessesByName("HandBrake").Length > 0 ? true : false;\r
             }\r
-\r
-            Process hbProcess = null;\r
-            foreach (Process process in hbProcesses)\r
-            {\r
-                bool found = false;\r
-                // Check if the current CLI instance was running before we started the current one\r
-                foreach (Process bprocess in before)\r
-                {\r
-                    if (process.Id == bprocess.Id)\r
-                        found = true;\r
-                }\r
-\r
-                // If it wasn't running before, we found the process we want.\r
-                if (!found)\r
-                {\r
-                    hbProcess = process;\r
-                    break;\r
-                }\r
-            }\r
-            if (hbProcess != null)\r
-                return hbProcess.Id;\r
-\r
-            return -1;\r
         }\r
 \r
         /// <summary>\r
@@ -457,8 +431,7 @@ namespace Handbrake.Functions
                 FileInfo[] logFiles = info.GetFiles("*.txt");\r
                 foreach (FileInfo file in logFiles)\r
                 {\r
-                    if (!file.Name.Contains("last_scan_log") && !file.Name.Contains("last_encode_log") &&\r
-                        !file.Name.Contains("tmp_appReadable_log.txt"))\r
+                    if (!file.Name.Contains("last_scan_log") && !file.Name.Contains("last_encode_log"))\r
                         File.Delete(file.FullName);\r
                 }\r
             }\r
@@ -479,8 +452,7 @@ namespace Handbrake.Functions
                 {\r
                     if (file.LastWriteTime < DateTime.Now.AddDays(-30))\r
                     {\r
-                        if (!file.Name.Contains("last_scan_log") && !file.Name.Contains("last_encode_log") &&\r
-                            !file.Name.Contains("tmp_appReadable_log.txt"))\r
+                        if (!file.Name.Contains("last_scan_log.txt") && !file.Name.Contains("last_encode_log.txt"))\r
                             File.Delete(file.FullName);\r
                     }\r
                 }\r
index c8f15c3..7f1e1ed 100644 (file)
@@ -16,8 +16,8 @@ namespace HandBrake.ApplicationServices
         /// <summary>\r
         /// Setup the Settings used by the applicaiton with this library\r
         /// </summary>\r
-        /// <param name="cli_minimized">\r
-        /// The cli_minimized.\r
+        /// <param name="instanceId">\r
+        /// The Instance ID\r
         /// </param>\r
         /// <param name="completionOption">\r
         /// The completion option.\r
@@ -25,9 +25,6 @@ namespace HandBrake.ApplicationServices
         /// <param name="disableDvdNav">\r
         /// The disable dvd nav.\r
         /// </param>\r
-        /// <param name="enocdeStatusInGui">\r
-        /// The enocde status in gui.\r
-        /// </param>\r
         /// <param name="growlEncode">\r
         /// The growl encode.\r
         /// </param>\r
@@ -52,10 +49,11 @@ namespace HandBrake.ApplicationServices
         /// <param name="preventSleep">\r
         /// Prevent the system from sleeping\r
         /// </param>\r
-        public static void SetupSettings(string completionOption, bool disableDvdNav,\r
+        public static void SetupSettings(int instanceId, string completionOption, bool disableDvdNav,\r
                                   bool growlEncode, bool growlQueue, string processPriority, string saveLogPath, bool saveLogToSpecifiedPath,\r
                                   bool saveLogWithVideo, bool showCliForInGuiEncodeStatus, bool preventSleep)\r
         {\r
+            InstanceId = instanceId;\r
             Properties.Settings.Default.CompletionOption = completionOption;\r
             Properties.Settings.Default.disableDvdNav = disableDvdNav;\r
             Properties.Settings.Default.growlEncode = growlEncode;\r
@@ -80,5 +78,7 @@ namespace HandBrake.ApplicationServices
         {\r
             return Assembly.GetExecutingAssembly().GetName().Version;\r
         }\r
+\r
+        public static int InstanceId;\r
     }\r
 }\r
index e5dc74c..f0a2b1f 100644 (file)
@@ -159,13 +159,13 @@ namespace HandBrake.ApplicationServices.Services
 \r
                 string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");\r
                 ProcessStartInfo cliStart = new ProcessStartInfo(handbrakeCLIPath, encJob.Query)\r
-                { \r
+                {\r
                     RedirectStandardOutput = true,\r
                     RedirectStandardError = enableLogging ? true : false,\r
                     UseShellExecute = false,\r
                     CreateNoWindow = !Settings.Default.showCliForInGuiEncodeStatus ? true : false\r
                 };\r
-              \r
+\r
                 this.HbProcess = Process.Start(cliStart);\r
 \r
                 if (enableLogging)\r
@@ -213,8 +213,8 @@ namespace HandBrake.ApplicationServices.Services
             }\r
             catch (Exception exc)\r
             {\r
-                Main.ShowExceptiowWindow("It would appear that HandBrakeCLI has not started correctly."\r
-                "You should take a look at the Activity log as it may indicate the reason why.\n\nDetailed Error Information: error occured in runCli()", \r
+                Main.ShowExceptiowWindow("It would appear that HandBrakeCLI has not started correctly." +\r
+                "You should take a look at the Activity log as it may indicate the reason why.\n\nDetailed Error Information: error occured in runCli()",\r
                 exc.ToString());\r
             }\r
         }\r
@@ -227,11 +227,7 @@ namespace HandBrake.ApplicationServices.Services
             try\r
             {\r
                 if (this.HbProcess != null) this.HbProcess.Kill();\r
-\r
-                Process[] list = Process.GetProcessesByName("HandBrakeCLI");\r
-                foreach (Process process in list)\r
-                    process.Kill();\r
-            } \r
+            }\r
             catch (Exception exc)\r
             {\r
                 Main.ShowExceptiowWindow("Unable to stop HandBrakeCLI. It may not be running.", exc.ToString());\r
@@ -272,36 +268,12 @@ namespace HandBrake.ApplicationServices.Services
         /// </param>\r
         private static string CreateCliLogHeader(Job encJob)\r
         {\r
-            try\r
-            {\r
-                //string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +\r
-                //                "\\HandBrake\\logs";\r
-                //string logPath = Path.Combine(logDir, "last_encode_log.txt");\r
-\r
-                //var reader = new StreamReader(File.Open(logPath, FileMode.Open, FileAccess.Read, FileShare.Read));\r
-                //string log = reader.ReadToEnd();\r
-                //reader.Close();\r
-\r
-                //var writer = new StreamWriter(File.Create(logPath));\r
-\r
+            StringBuilder logHeader = new StringBuilder();\r
+            logHeader.AppendLine("# CLI Query: " + encJob.Query);\r
+            logHeader.AppendLine("# User Query: " + encJob.CustomQuery);\r
+            logHeader.AppendLine("-------------------------------------------");\r
 \r
-                //writer.WriteLine("### CLI Query: " + encJob.Query);\r
-                //writer.WriteLine("### User Query: " + encJob.CustomQuery);\r
-                //writer.WriteLine("#########################################");\r
-                //writer.WriteLine(log);\r
-                //writer.Flush();\r
-                //writer.Close();\r
-                StringBuilder logHeader = new StringBuilder();\r
-                logHeader.AppendLine("### CLI Query: " + encJob.Query);\r
-                logHeader.AppendLine("### User Query: " + encJob.CustomQuery);\r
-                logHeader.AppendLine("#########################################");\r
-\r
-                return logHeader.ToString();\r
-            }\r
-            catch (Exception)\r
-            {\r
-                return string.Empty;\r
-            }\r
+            return logHeader.ToString();\r
         }\r
 \r
         /// <summary>\r
@@ -317,7 +289,7 @@ namespace HandBrake.ApplicationServices.Services
             {\r
                 string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +\r
                                 "\\HandBrake\\logs";\r
-                string tempLogFile = Path.Combine(logDir, "last_encode_log.txt");\r
+                string tempLogFile = Path.Combine(logDir, string.Format("last_encode_log{0}.txt", Init.InstanceId));\r
 \r
                 string encodeDestinationPath = Path.GetDirectoryName(destination);\r
                 string destinationFile = Path.GetFileName(destination);\r
@@ -378,8 +350,8 @@ namespace HandBrake.ApplicationServices.Services
             {\r
                 if (fileWriter != null)\r
                     fileWriter.Close();\r
-            } \r
-            catch(Exception exc)\r
+            }\r
+            catch (Exception exc)\r
             {\r
                 Main.ShowExceptiowWindow("Unable to close the log file wrtier", exc.ToString());\r
             }\r
@@ -399,8 +371,8 @@ namespace HandBrake.ApplicationServices.Services
                 // last_encode_log.txt is the primary log file. Since .NET can't read this file whilst the CLI is outputing to it (Not even in read only mode),\r
                 // we'll need to make a copy of it.\r
                 string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
-                string logFile = Path.Combine(logDir, "last_encode_log.txt");\r
-                string logFile2 = Path.Combine(logDir, "tmp_appReadable_log.txt");\r
+                string logFile = Path.Combine(logDir, string.Format("last_encode_log{0}.txt", Init.InstanceId));\r
+                string logFile2 = Path.Combine(logDir, string.Format("tmp_appReadable_log{0}.txt", Init.InstanceId));\r
                 int logFilePosition = 0;\r
 \r
                 try\r
@@ -414,7 +386,7 @@ namespace HandBrake.ApplicationServices.Services
                         File.Copy(logFile, logFile2, true);\r
                     else\r
                         return;\r
\r
+\r
                     // Start the Reader\r
                     // Only use text which continues on from the last read line\r
                     StreamReader sr = new StreamReader(logFile2);\r
@@ -445,8 +417,8 @@ namespace HandBrake.ApplicationServices.Services
         private void SetupLogging(Job encodeJob)\r
         {\r
             string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
-            string logFile = Path.Combine(logDir, "last_encode_log.txt");\r
-            string logFile2 = Path.Combine(logDir, "tmp_appReadable_log.txt");\r
+            string logFile = Path.Combine(logDir, string.Format("last_encode_log{0}.txt", Init.InstanceId));\r
+            string logFile2 = Path.Combine(logDir, string.Format("tmp_appReadable_log{0}.txt", Init.InstanceId));\r
 \r
             try\r
             {\r
@@ -493,7 +465,7 @@ namespace HandBrake.ApplicationServices.Services
                 catch (Exception exc)\r
                 {\r
                     Main.ShowExceptiowWindow("Unable to write log data...", exc.ToString());\r
-                }         \r
+                }\r
             }\r
         }\r
 \r
index da32d25..7ba1d9d 100644 (file)
@@ -104,7 +104,7 @@ namespace HandBrake.ApplicationServices.Services
             this.LastEncode = job;\r
             this.Remove(0); // Remove the item which we are about to pass out.\r
 \r
-            this.WriteQueueStateToFile("hb_queue_recovery.xml");\r
+            this.SaveQueue();\r
 \r
             return job;\r
         }\r
@@ -140,7 +140,7 @@ namespace HandBrake.ApplicationServices.Services
                              };\r
 \r
             this.queue.Add(newJob);\r
-            this.WriteQueueStateToFile("hb_queue_recovery.xml");\r
+            this.SaveQueue();\r
 \r
             if (this.QueueListChanged != null)\r
                 this.QueueListChanged(this, new EventArgs());\r
@@ -153,7 +153,7 @@ namespace HandBrake.ApplicationServices.Services
         public void Remove(int index)\r
         {\r
             this.queue.RemoveAt(index);\r
-            this.WriteQueueStateToFile("hb_queue_recovery.xml");\r
+            this.SaveQueue();\r
 \r
             if (this.QueueListChanged != null)\r
                 this.QueueListChanged(this, new EventArgs());\r
@@ -186,7 +186,7 @@ namespace HandBrake.ApplicationServices.Services
                 queue.Insert((index - 1), item);\r
             }\r
 \r
-            WriteQueueStateToFile("hb_queue_recovery.xml"); // Update the queue recovery file\r
+            this.SaveQueue(); // Update the queue recovery file\r
 \r
             if (this.QueueListChanged != null)\r
                 this.QueueListChanged(this, new EventArgs());\r
@@ -206,11 +206,22 @@ namespace HandBrake.ApplicationServices.Services
                 this.queue.Insert((index + 1), item);\r
             }\r
 \r
-            this.WriteQueueStateToFile("hb_queue_recovery.xml"); // Update the queue recovery file\r
+            this.SaveQueue(); // Update the queue recovery file\r
 \r
             if (this.QueueListChanged != null)\r
                 this.QueueListChanged(this, new EventArgs());\r
         }\r
+        \r
+        /// <summary>\r
+        /// Save any updates to the main queue file.\r
+        /// </summary>\r
+        public void SaveQueue()\r
+        {\r
+            string file = Init.InstanceId == 0\r
+                              ? "hb_queue_recovery.xml"\r
+                              : string.Format("hb_queue_recovery{0}.xml", Init.InstanceId);\r
+            this.WriteQueueStateToFile(file);\r
+        }\r
 \r
         /// <summary>\r
         /// Writes the current state of the queue to a file.\r
@@ -218,9 +229,8 @@ namespace HandBrake.ApplicationServices.Services
         /// <param name="file">The location of the file to write the queue to.</param>\r
         public void WriteQueueStateToFile(string file)\r
         {\r
-            string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),\r
-                                              @"HandBrake\hb_queue_recovery.xml");\r
-            string tempPath = file == "hb_queue_recovery.xml" ? appDataPath : file;\r
+            string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");\r
+            string tempPath = file.Contains("hb_queue_recovery") ? appDataPath + file : file;\r
 \r
             try\r
             {\r
@@ -285,9 +295,8 @@ namespace HandBrake.ApplicationServices.Services
         /// <param name="file">The location of the file to read the queue from.</param>\r
         public void LoadQueueFromFile(string file)\r
         {\r
-            string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),\r
-                                              @"HandBrake\hb_queue_recovery.xml");\r
-            string tempPath = file == "hb_queue_recovery.xml" ? appDataPath : file;\r
+            string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");\r
+            string tempPath = file.Contains("hb_queue_recovery") ? appDataPath + file : file;\r
 \r
             if (File.Exists(tempPath))\r
             {\r
@@ -304,8 +313,8 @@ namespace HandBrake.ApplicationServices.Services
                             foreach (Job item in list)\r
                                 this.queue.Add(item);\r
 \r
-                        if (file != "hb_queue_recovery.xml")\r
-                            this.WriteQueueStateToFile("hb_queue_recovery.xml");\r
+                        if (!file.Contains("hb_queue_recovery"))\r
+                            this.SaveQueue();\r
 \r
                         if (this.QueueListChanged != null)\r
                             this.QueueListChanged(this, new EventArgs());\r
@@ -378,7 +387,7 @@ namespace HandBrake.ApplicationServices.Services
             while (this.Count != 0)\r
             {\r
                 Job encJob = this.GetNextJob();\r
-                this.WriteQueueStateToFile("hb_queue_recovery.xml"); // Update the queue recovery file\r
+                this.SaveQueue(); // Update the queue recovery file\r
 \r
                 Run(encJob, true);\r
 \r
index 6aefa03..039cb3f 100644 (file)
@@ -154,7 +154,7 @@ namespace HandBrake.ApplicationServices.Services
                 string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");\r
                 string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +\r
                                 "\\HandBrake\\logs";\r
-                string dvdInfoPath = Path.Combine(logDir, "last_scan_log.txt");\r
+                string dvdInfoPath = Path.Combine(logDir, string.Format("last_scan_log{0}.txt", Init.InstanceId));\r
 \r
                 // Make we don't pick up a stale last_encode_log.txt (and that we have rights to the file)\r
                 if (File.Exists(dvdInfoPath))\r
@@ -218,8 +218,8 @@ namespace HandBrake.ApplicationServices.Services
                 // we'll need to make a copy of it.\r
                 string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +\r
                                 "\\HandBrake\\logs";\r
-                string logFile = Path.Combine(logDir, "last_scan_log.txt");\r
-                string logFile2 = Path.Combine(logDir, "tmp_appReadable_log.txt");\r
+                string logFile = Path.Combine(logDir, string.Format("last_scan_log{0}.txt", Init.InstanceId));\r
+                string logFile2 = Path.Combine(logDir, string.Format("tmp_appReadable_log{0}.txt", Init.InstanceId));\r
 \r
                 try\r
                 {\r
index 6480b50..f54a775 100644 (file)
@@ -6,6 +6,7 @@
 namespace Handbrake\r
 {\r
     using System;\r
+    using System.Diagnostics;\r
     using System.IO;\r
     using System.Windows.Forms;\r
 \r
@@ -26,6 +27,8 @@ namespace Handbrake
         [STAThread]\r
         public static void Main(string[] args)\r
         {\r
+            InstanceId = Process.GetProcessesByName("HandBrake").Length;\r
+\r
             // Handle any unhandled exceptions\r
             AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);\r
 \r
@@ -88,7 +91,7 @@ namespace Handbrake
         /// </summary>\r
         private static void InitializeApplicationServices()\r
         {\r
-            Init.SetupSettings(Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
+            Init.SetupSettings(InstanceId, Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
                                Settings.Default.growlEncode, Settings.Default.growlQueue,\r
                                Settings.Default.processPriority, Settings.Default.saveLogPath, Settings.Default.saveLogToSpecifiedPath,\r
                                Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus, Settings.Default.preventSleep);\r
@@ -116,5 +119,10 @@ namespace Handbrake
                     MessageBoxIcon.Error);\r
             }\r
         }\r
+\r
+\r
+        public static int InstanceId = 0;\r
+\r
+\r
     }\r
 }
\ No newline at end of file
index 7f46139..91ed404 100644 (file)
@@ -211,21 +211,37 @@ namespace Handbrake
         // Startup Functions   \r
         private void queueRecovery()\r
         {\r
-            if (Main.CheckQueueRecovery())\r
+            DialogResult result = DialogResult.None;\r
+            List<string> queueFiles = Main.CheckQueueRecovery();\r
+            if (queueFiles.Count == 1)\r
             {\r
-                DialogResult result =\r
-                    MessageBox.Show(\r
+                result = MessageBox.Show(\r
                         "HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?",\r
                         "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+            }\r
+            else if (queueFiles.Count > 1)\r
+            {\r
+                result = MessageBox.Show(\r
+                        "HandBrake has detected multiple unfinished queue files. These will be from multiple instances of HandBrake running. Would you like to recover all unfinished jobs?",\r
+                        "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+            }\r
 \r
-                if (result == DialogResult.Yes)\r
-                    encodeQueue.LoadQueueFromFile("hb_queue_recovery.xml"); // Start Recovery\r
-                else\r
+            if (result == DialogResult.Yes)\r
+            {\r
+                foreach (string file in queueFiles)\r
+                {\r
+                    encodeQueue.LoadQueueFromFile(file); // Start Recovery\r
+                }\r
+            }\r
+            else\r
+            {\r
+                if (Main.IsMultiInstance) return; // Don't tamper with the files if we are multi instance\r
+\r
+                string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\");\r
+                foreach (string file in queueFiles)\r
                 {\r
-                    // Remove the Queue recovery file if the user doesn't want to recovery the last queue.\r
-                    string queuePath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml");\r
-                    if (File.Exists(queuePath))\r
-                        File.Delete(queuePath);\r
+                    if (File.Exists(Path.Combine(tempPath, file)))\r
+                        File.Delete(Path.Combine(tempPath, file));\r
                 }\r
             }\r
         }\r
index 492ee35..7ca71dc 100644 (file)
@@ -473,7 +473,7 @@ namespace Handbrake
         /// </summary>\r
         private static void UpdateApplicationServicesSettings()\r
         {\r
-            Init.SetupSettings(Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
+            Init.SetupSettings(Program.InstanceId, Settings.Default.CompletionOption, Settings.Default.noDvdNav,\r
                                Settings.Default.growlEncode, Settings.Default.growlQueue,\r
                                Settings.Default.processPriority, Settings.Default.saveLogPath, Settings.Default.saveLogToSpecifiedPath,\r
                                Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus, Settings.Default.preventSleep);\r