diff --git a/MLEM/Misc/GenericDataHolder.cs b/MLEM/Misc/GenericDataHolder.cs index d9660bd..beb75dc 100644 --- a/MLEM/Misc/GenericDataHolder.cs +++ b/MLEM/Misc/GenericDataHolder.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; namespace MLEM.Misc { @@ -6,11 +7,12 @@ namespace MLEM.Misc { private Dictionary data; public void SetData(string key, object data) { - if (this.data == null) - this.data = new Dictionary(); if (data == default) { - this.data.Remove(key); + if (this.data != null) + this.data.Remove(key); } else { + if (this.data == null) + this.data = new Dictionary(); this.data[key] = data; } } @@ -22,6 +24,8 @@ namespace MLEM.Misc { } public IReadOnlyCollection GetDataKeys() { + if (this.data == null) + return Array.Empty(); return this.data.Keys; }