Improve guards for theme loading
This commit is contained in:
parent
367c3b67eb
commit
819d7ef453
2 changed files with 13 additions and 3 deletions
|
|
@ -79,8 +79,18 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public ThemeSet GetTheme(string themeName, Color accentColor)
|
||||
{
|
||||
var themeset = JsonConvert.DeserializeObject<ThemeSet>(
|
||||
AggContext.StaticData.ReadAllText(Path.Combine(path, themeName + ".json")));
|
||||
ThemeSet themeset = null;
|
||||
|
||||
try
|
||||
{
|
||||
themeset = JsonConvert.DeserializeObject<ThemeSet>(
|
||||
AggContext.StaticData.ReadAllText(Path.Combine(path, themeName + ".json")));
|
||||
}
|
||||
catch
|
||||
{
|
||||
themeset = JsonConvert.DeserializeObject<ThemeSet>(
|
||||
AggContext.StaticData.ReadAllText(Path.Combine(path, this.ThemeNames.First() + ".json")));
|
||||
}
|
||||
|
||||
themeset.ThemeID = themeName;
|
||||
themeset.SetAccentColor(accentColor);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue