]> granicus.if.org Git - handbrake/commitdiff
WinGui: Put up a clearer error when we can't read older presets rather than just...
authorsr55 <sr55.hb@outlook.com>
Thu, 12 Jan 2017 21:21:33 +0000 (21:21 +0000)
committersr55 <sr55.hb@outlook.com>
Thu, 12 Jan 2017 21:21:59 +0000 (21:21 +0000)
win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs
win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
win/CS/HandBrakeWPF/Properties/Resources.resx
win/CS/HandBrakeWPF/Services/Presets/PresetService.cs

index 7e1f95d3e4a1cf968d906ceed8b813e08be13583..38ebb35156b87622d46955af46ccf97606744e6e 100644 (file)
@@ -62,12 +62,15 @@ namespace HandBrake.ApplicationServices.Interop
         {\r
             IntPtr presetStringPointer = HBFunctions.hb_presets_read_file_json(InteropUtilities.ToUtf8PtrFromString(filename));\r
             string presetJson = Marshal.PtrToStringAnsi(presetStringPointer);\r
-\r
             log.LogMessage(presetJson, LogMessageType.API, LogLevel.Debug);\r
 \r
-            PresetTransportContainer preset = JsonConvert.DeserializeObject<PresetTransportContainer>(presetJson);\r
+            if (!string.IsNullOrEmpty(presetJson))\r
+            {\r
+                PresetTransportContainer preset = JsonConvert.DeserializeObject<PresetTransportContainer>(presetJson);\r
+                return preset;\r
+            }\r
 \r
-            return preset;\r
+            return null;\r
         }\r
 \r
         /// <summary>\r
index aec34eaebc078bd99a77105d21b36d365c8d9235..d218534498fde163a89bd408bf27345278ba78b6 100644 (file)
@@ -1154,6 +1154,15 @@ namespace HandBrakeWPF.Properties {
             }\r
         }\r
         \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to No Additional Information.\r
+        /// </summary>\r
+        public static string NoAdditionalInformation {\r
+            get {\r
+                return ResourceManager.GetString("NoAdditionalInformation", resourceCulture);\r
+            }\r
+        }\r
+        \r
         /// <summary>\r
         ///   Looks up a localized string similar to Notice.\r
         /// </summary>\r
index 0fae87bf4ca717eecb9a0d3a0d271083beccec09..ed52a4a8f8f400fd3fc8342746b100b75b49bae7 100644 (file)
@@ -830,4 +830,7 @@ Your preset file will be archived and new one created. You will need to re-creat
   <data name="MainViewModel_EncodeStatusChanged_SubScan_StatusLabel" xml:space="preserve">\r
     <value>Processing Pass {0} of {1}, (Subtitle Scan)  {2:00.00}%, Scan Time Remaining: {3},  Elapsed: {4:d\:hh\:mm\:ss}</value>\r
   </data>\r
+  <data name="NoAdditionalInformation" xml:space="preserve">\r
+    <value>No Additional Information</value>\r
+  </data>\r
 </root>
\ No newline at end of file
index 6869b89a2301f5e07f9ff85ba7ec70c668986a61..78387e54e59f248b170eef4d30a6b46b815ebabd 100644 (file)
@@ -142,11 +142,20 @@ namespace HandBrakeWPF.Services.Presets
         {\r
             if (!string.IsNullOrEmpty(filename))\r
             {\r
-                PresetTransportContainer container = HandBrakePresetService.GetPresetFromFile(filename);\r
+                PresetTransportContainer container = null;\r
+                try\r
+                {\r
+                    container = HandBrakePresetService.GetPresetFromFile(filename);\r
+                }\r
+                catch (Exception exc)\r
+                {\r
+                    this.errorService.ShowError(Resources.Main_PresetImportFailed, Resources.Main_PresetImportFailedSolution, exc);\r
+                    return;\r
+                }\r
 \r
                 if (container?.PresetList == null || container.PresetList.Count == 0)\r
                 {\r
-                    this.errorService.ShowError(Resources.Main_PresetImportFailed, Resources.Main_PresetImportFailedSolution, string.Empty);\r
+                    this.errorService.ShowError(Resources.Main_PresetImportFailed, Resources.Main_PresetImportFailedSolution, Resources.NoAdditionalInformation);\r
                     return;\r
                 }\r
 \r