From ef5ef9316727886a9af3aa8485da74c23ce6680f Mon Sep 17 00:00:00 2001 From: Tarek Khalil Date: Sat, 24 Sep 2016 22:25:11 +0100 Subject: [PATCH 1/2] Synchronising both _viewTypeDataDictionary and ViewTypeDataList in ViewPresenter --- .../Assets/MarkLight/Source/Plugins/ViewPresenter.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/Assets/MarkLight/Source/Plugins/ViewPresenter.cs b/Source/Assets/MarkLight/Source/Plugins/ViewPresenter.cs index f81376b..cfb3c3a 100644 --- a/Source/Assets/MarkLight/Source/Plugins/ViewPresenter.cs +++ b/Source/Assets/MarkLight/Source/Plugins/ViewPresenter.cs @@ -228,10 +228,14 @@ public void Clear() /// public ViewTypeData GetViewTypeData(string viewTypeName) { - if (_viewTypeDataDictionary == null) - { - LoadViewTypeDataDictionary(); - } + // We attempt to reload the ViewTypeDataDictionary in case the ViewTypeDataList is updated + // through the creation of a new ViewTypeData instance. + // + // E.g.: ViewData.CreateView(....) + if (_viewTypeDataDictionary == null || _viewTypeDataDictionary.Count < ViewTypeDataList.Count) + { + LoadViewTypeDataDictionary(); + } ViewTypeData viewTypeData; if (!_viewTypeDataDictionary.TryGetValue(viewTypeName, out viewTypeData)) From 15182b045819ccb9330af959a9ad331b1241dea7 Mon Sep 17 00:00:00 2001 From: Tarek Khalil Date: Sat, 24 Sep 2016 22:29:28 +0100 Subject: [PATCH 2/2] Adjust formatting --- .../Assets/MarkLight/Source/Plugins/ViewPresenter.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Assets/MarkLight/Source/Plugins/ViewPresenter.cs b/Source/Assets/MarkLight/Source/Plugins/ViewPresenter.cs index cfb3c3a..3d8aad8 100644 --- a/Source/Assets/MarkLight/Source/Plugins/ViewPresenter.cs +++ b/Source/Assets/MarkLight/Source/Plugins/ViewPresenter.cs @@ -237,12 +237,12 @@ public ViewTypeData GetViewTypeData(string viewTypeName) LoadViewTypeDataDictionary(); } - ViewTypeData viewTypeData; - if (!_viewTypeDataDictionary.TryGetValue(viewTypeName, out viewTypeData)) - { - Utils.LogError("[MarkLight] Can't find view type \"{0}\".", viewTypeName); - return null; - } + ViewTypeData viewTypeData; + if (!_viewTypeDataDictionary.TryGetValue(viewTypeName, out viewTypeData)) + { + Utils.LogError("[MarkLight] Can't find view type \"{0}\".", viewTypeName); + return null; + } return viewTypeData; }