Skip to content

Commit

Permalink
Only call UpdateEnumValues for relevant caller types and add null che…
Browse files Browse the repository at this point in the history
…ck as extra protection
  • Loading branch information
IsakNaslundBh authored and Fraser Greenroyd committed Nov 4, 2022
1 parent 8ce7467 commit 9588814
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Excel_UI/Addin/AddIn_Formulas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ public static void RestoreFormulas()
IAddObject(choice);
}

UpdateEnumValues(valueList.MultiChoiceCaller.SelectedItem.ToJson());
if(valueList is CreateEnumFormula)
UpdateEnumValues(valueList.MultiChoiceCaller.SelectedItem.ToJson());
}
}
}
Expand All @@ -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;
Expand Down

0 comments on commit 9588814

Please sign in to comment.