Prevent frequently occurring exception during parse

This commit is contained in:
John Lewin 2016-05-18 11:04:06 -07:00
parent 6a84736f1f
commit 8a73db2ba0

View file

@ -271,14 +271,12 @@ namespace MatterHackers.MatterControl
/// </summary>
public void SwitchToPrinterThemeWithoutReloadEvent()
{
string activeThemeIndex = ActiveSliceSettings.Instance.ActiveValue("MatterControl.ActiveThemeIndex");
int themeIndex;
try
if (string.IsNullOrEmpty(activeThemeIndex) || !int.TryParse(activeThemeIndex, out themeIndex))
{
themeIndex = Convert.ToInt32(ActiveSliceSettings.Instance.ActiveValue("MatterControl.ActiveThemeIndex"));
}
catch
{
GuiWidget.BreakInDebugger();
// Fall back to default theme if user settings are missing or invalid
themeIndex = defaultThemeIndex;
}