]> granicus.if.org Git - handbrake/commitdiff
WinGui:
authorsr55 <sr55.hb@outlook.com>
Sat, 19 Dec 2009 00:00:41 +0000 (00:00 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 19 Dec 2009 00:00:41 +0000 (00:00 +0000)
- Shave ~0.5s of the application startup time by not initialising an XmlSerializer when it's not needed. This is quite expensive.
- Make sure the Activity window is initialised before we try set it's title.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3035 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/EncodeQueue/EncodeAndQueueHandler.cs
win/C#/frmActivityWindow.cs
win/C#/frmMain.cs

index db91e6d9008f207d706ac727a54473021f713c8a..17db752937a4d868fc214d3fe21196a0217a1b0c 100644 (file)
@@ -18,7 +18,7 @@ namespace Handbrake.EncodeQueue
 {\r
     public class EncodeAndQueueHandler\r
     {\r
-        private static XmlSerializer serializer = new XmlSerializer(typeof(List<Job>));\r
+        private static XmlSerializer serializer;\r
         private List<Job> queue = new List<Job>();\r
         private int nextJobId;\r
 \r
@@ -148,6 +148,8 @@ namespace Handbrake.EncodeQueue
             {\r
                 using (FileStream strm = new FileStream(tempPath, FileMode.Create, FileAccess.Write))\r
                 {\r
+                    if (serializer == null)\r
+                        serializer = new XmlSerializer(typeof(List<Job>));\r
                     serializer.Serialize(strm, queue);\r
                     strm.Close();\r
                     strm.Dispose();\r
@@ -215,6 +217,9 @@ namespace Handbrake.EncodeQueue
                 {\r
                     if (strm.Length != 0)\r
                     {\r
+                        if (serializer == null)\r
+                            serializer = new XmlSerializer(typeof(List<Job>));\r
+\r
                         List<Job> list = serializer.Deserialize(strm) as List<Job>;\r
 \r
                         if (list != null)\r
@@ -325,7 +330,7 @@ namespace Handbrake.EncodeQueue
 \r
                 hbProcess.Close();\r
                 hbProcess.Dispose();\r
-                \r
+\r
                 isEncoding = false;\r
 \r
                 //Growl\r
@@ -383,7 +388,7 @@ namespace Handbrake.EncodeQueue
 \r
                 Process[] before = Process.GetProcesses(); // Get a list of running processes before starting.\r
                 hbProcess = Process.Start(cliStart);\r
-                processID = Main.getCliProcess(before); \r
+                processID = Main.getCliProcess(before);\r
                 currentQuery = query;\r
                 if (hbProcess != null)\r
                     processHandle = hbProcess.MainWindowHandle; // Set the process Handle\r
index 5f41c799bd50d4fcd7a31ef6d986c90bf888aa7a..9d004ffc722cffaa90ea17e61a77eb764e71fab2 100644 (file)
@@ -28,14 +28,14 @@ namespace Handbrake
 \r
         public frmActivityWindow(string mode)\r
         {\r
+            InitializeComponent();\r
+\r
             _kilLThread = false;\r
             _position = 0;\r
             if (mode == "scan")\r
                 SetScanMode();\r
             else\r
                 SetEncodeMode();\r
-\r
-            InitializeComponent();\r
         }\r
         private void NewActivityWindow_Load(object sender, EventArgs e)\r
         {\r
index c6fb58e60c861ae3c02139039bf1fbf639ac5f17..87ea63e92a0bb69af9ed1b278d86e4918852a579 100644 (file)
@@ -192,8 +192,8 @@ namespace Handbrake
                 {\r
                     return this.dvdDriveLabel;\r
                 }\r
-                \r
-                if(Path.GetFileNameWithoutExtension(this.sourcePath) != "VIDEO_TS")\r
+\r
+                if (Path.GetFileNameWithoutExtension(this.sourcePath) != "VIDEO_TS")\r
                     return Path.GetFileNameWithoutExtension(this.sourcePath);\r
 \r
                 return Path.GetFileNameWithoutExtension(Path.GetDirectoryName(this.sourcePath));\r
@@ -789,19 +789,19 @@ namespace Handbrake
         {\r
             if (ActivityWindow == null || !ActivityWindow.IsHandleCreated)\r
                 ActivityWindow = new frmActivityWindow(lastAction);\r
-\r
-            switch (lastAction)\r
-            {\r
-                case "scan":\r
-                    ActivityWindow.SetScanMode();\r
-                    break;\r
-                case "encode":\r
-                    ActivityWindow.SetEncodeMode();\r
-                    break;\r
-                default:\r
-                    ActivityWindow.SetEncodeMode();\r
-                    break;\r
-            }\r
+            else\r
+                switch (lastAction)\r
+                {\r
+                    case "scan":\r
+                        ActivityWindow.SetScanMode();\r
+                        break;\r
+                    case "encode":\r
+                        ActivityWindow.SetEncodeMode();\r
+                        break;\r
+                    default:\r
+                        ActivityWindow.SetEncodeMode();\r
+                        break;\r
+                }\r
 \r
             ActivityWindow.Show();\r
             ActivityWindow.Activate();\r