Prevent unhandled exceptions when indexing into OemProfiles
- Return null on caught exceptions - Issue MatterHackers/MatterControl#1285
This commit is contained in:
parent
d4c0751505
commit
70899bbedf
1 changed files with 13 additions and 9 deletions
|
|
@ -298,18 +298,22 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
public static PrinterSettings RestoreFromOemProfile(PrinterInfo profile)
|
||||
{
|
||||
string publicProfileDeviceToken = OemSettings.Instance.OemProfiles[profile.Make][profile.Model];
|
||||
string publicProfileToLoad = Path.Combine(ApplicationDataStorage.ApplicationUserDataPath, "data", "temp", "cache", "profiles", publicProfileDeviceToken + ProfileManager.ProfileExtension);
|
||||
PrinterSettings oemProfile = null;
|
||||
|
||||
var oemProfile = JsonConvert.DeserializeObject<PrinterSettings>(File.ReadAllText(publicProfileToLoad));
|
||||
oemProfile.ID = profile.ID;
|
||||
oemProfile.SetValue(SettingsKey.printer_name, profile.Name);
|
||||
oemProfile.DocumentVersion = PrinterSettings.LatestVersion;
|
||||
try
|
||||
{
|
||||
string publicProfileDeviceToken = OemSettings.Instance.OemProfiles[profile.Make][profile.Model];
|
||||
string publicProfileToLoad = Path.Combine(ApplicationDataStorage.ApplicationUserDataPath, "data", "temp", "cache", "profiles", publicProfileDeviceToken + ProfileManager.ProfileExtension);
|
||||
|
||||
oemProfile.Helpers.SetComPort(profile.ComPort);
|
||||
oemProfile.Save();
|
||||
oemProfile = JsonConvert.DeserializeObject<PrinterSettings>(File.ReadAllText(publicProfileToLoad));
|
||||
oemProfile.ID = profile.ID;
|
||||
oemProfile.SetValue(SettingsKey.printer_name, profile.Name);
|
||||
oemProfile.DocumentVersion = PrinterSettings.LatestVersion;
|
||||
|
||||
//WarnAboutRevert(profile);
|
||||
oemProfile.Helpers.SetComPort(profile.ComPort);
|
||||
oemProfile.Save();
|
||||
}
|
||||
catch { }
|
||||
|
||||
return oemProfile;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue