From 52328cc18de3828e79f27b071ebc866c18ca9987 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 26 Apr 2020 02:19:58 +0200 Subject: [PATCH] fixed GenericDataHolder nre --- MLEM/Misc/GenericDataHolder.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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; }