]> granicus.if.org Git - handbrake/commitdiff
WinGui: Fix a couple of silent errors with the new logging system.
authorsr55 <sr55.hb@outlook.com>
Sat, 26 Mar 2016 19:27:11 +0000 (19:27 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 26 Mar 2016 19:27:11 +0000 (19:27 +0000)
win/CS/HandBrakeWPF/Helpers/LogManager.cs
win/CS/HandBrakeWPF/Views/LogView.xaml.cs

index 4e883f8ee5a99ecaf7c2d1c0f3013d643a866ce0..70347fca16ecbb79782eb6b41813ae00b106c214 100644 (file)
@@ -31,6 +31,11 @@ namespace HandBrakeWPF.Helpers
             ILog log = LogService.GetLogger();
             string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
             string logFile = Path.Combine(logDir, string.Format("activity_log{0}.txt", GeneralUtilities.ProcessId));
+            if (!Directory.Exists(Path.GetDirectoryName(logFile)))
+            {
+                Directory.CreateDirectory(Path.GetDirectoryName(logFile));
+            }
+
             log.Enable();
             log.SetupLogHeader(GeneralUtilities.CreateLogHeader().ToString());
             log.EnableLoggingToDisk(logFile, true);
index 2ab42775299270ba9cdb5fca3323cb56432eee7a..67d2f21dfdcb02271022652bcc53d2cea7576533 100644 (file)
@@ -60,28 +60,39 @@ namespace HandBrakeWPF.Views
         /// </param>\r
         private void Vm_LogMessageReceived(object sender, HandBrake.ApplicationServices.Services.Logging.EventArgs.LogEventArgs e)\r
         {\r
-            if (e == null)\r
+            try\r
             {\r
-                LogViewModel vm = this.DataContext as LogViewModel;\r
-                if (vm != null)\r
+                if (e == null)\r
                 {\r
-                    this.logText.Clear();\r
-                    this.logText.AppendText(vm.ActivityLog);\r
+                    Caliburn.Micro.Execute.OnUIThread(\r
+                        () =>\r
+                            {\r
+                                LogViewModel vm = this.DataContext as LogViewModel;\r
+                                if (vm != null)\r
+                                {\r
+                                    this.logText.Clear();\r
+                                    this.logText.AppendText(vm.ActivityLog);\r
+                                }\r
+                                else\r
+                                {\r
+                                    Debug.WriteLine("Failed to Reset Log correctly.");\r
+                                }\r
+                            });   \r
                 }\r
                 else\r
                 {\r
-                    Debug.WriteLine("Failed to Reset Log correctly.");\r
+                    // This works better than Data Binding because of the scroll.\r
+                    this.logText.AppendText(Environment.NewLine + e.Log.Content);\r
+\r
+                    if (this.AutoScroll.IsChecked)\r
+                    {\r
+                        this.logText.ScrollToEnd();\r
+                    }\r
                 }\r
             }\r
-            else\r
+            catch (Exception exc)\r
             {\r
-                // This works better than Data Binding because of the scroll.\r
-                this.logText.AppendText(Environment.NewLine + e.Log.Content);\r
-\r
-                if (this.AutoScroll.IsChecked)\r
-                {\r
-                    this.logText.ScrollToEnd();\r
-                }\r
+                Debug.WriteLine(exc);\r
             }\r
         }\r
 \r