From 219f407246263060632fd64861921ee4c89c074d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 14 Oct 2019 01:06:20 -0500 Subject: [PATCH] Fix JSON ParseError exporting settings if custom settings have never been edited. --- smx-config/Helpers.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/smx-config/Helpers.cs b/smx-config/Helpers.cs index 7ac0f6d..99b9900 100644 --- a/smx-config/Helpers.cs +++ b/smx-config/Helpers.cs @@ -508,7 +508,13 @@ namespace smx_config static public List GetCustomSensorsJSON() { - return SMXJSON.ParseJSON.Parse>(Properties.Settings.Default.CustomSensors); + try { + return SMXJSON.ParseJSON.Parse>(Properties.Settings.Default.CustomSensors); + } catch(ParseError) { + // CustomSensors is empty by default. We could test if it's empty, but as a more general + // safety, just catch any JSON errors in case something invalid is saved to it. + return new List(); + } } const int SensorLeft = 0;