From 958881483ff8b98569dc67f69a5a33b9837d094c Mon Sep 17 00:00:00 2001 From: Isak Naslund Date: Fri, 4 Nov 2022 09:11:54 +0100 Subject: [PATCH] Only call UpdateEnumValues for relevant caller types and add null check as extra protection --- Excel_UI/Addin/AddIn_Formulas.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Excel_UI/Addin/AddIn_Formulas.cs b/Excel_UI/Addin/AddIn_Formulas.cs index 84e314f..1614d64 100644 --- a/Excel_UI/Addin/AddIn_Formulas.cs +++ b/Excel_UI/Addin/AddIn_Formulas.cs @@ -137,7 +137,8 @@ public static void RestoreFormulas() IAddObject(choice); } - UpdateEnumValues(valueList.MultiChoiceCaller.SelectedItem.ToJson()); + if(valueList is CreateEnumFormula) + UpdateEnumValues(valueList.MultiChoiceCaller.SelectedItem.ToJson()); } } } @@ -151,7 +152,7 @@ private static void UpdateEnumValues(string collectionName) { //Update enum values in case they have changed since the last serialisation var enumType = BH.Engine.Serialiser.Convert.FromJson(collectionName) as Type; //To strip out the 'BHoM_Version' - if (!enumType.IsEnum) + if (enumType == null || !enumType.IsEnum) return; //This method is only for enum dropdowns, not datasets, etc. var nameOfEnum = enumType.Namespace + "." + enumType.Name;