From dc3c1a72a8d9631f8bb84f32ca011dc6fe21a1f7 Mon Sep 17 00:00:00 2001 From: kgiszewski Date: Tue, 3 May 2016 10:11:13 -0400 Subject: [PATCH] Add some null checks --- .../PropertyEditors/ArcheTypePropertyEditor.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Umbraco/Umbraco.Archetype/PropertyEditors/ArcheTypePropertyEditor.cs b/app/Umbraco/Umbraco.Archetype/PropertyEditors/ArcheTypePropertyEditor.cs index 219c9fc..d07ceee 100644 --- a/app/Umbraco/Umbraco.Archetype/PropertyEditors/ArcheTypePropertyEditor.cs +++ b/app/Umbraco/Umbraco.Archetype/PropertyEditors/ArcheTypePropertyEditor.cs @@ -95,7 +95,7 @@ namespace Archetype.PropertyEditors if(propDef == null || propDef.DataTypeGuid == null) continue; var dtd = ArchetypeHelper.Instance.GetDataTypeByGuid(Guid.Parse(propDef.DataTypeGuid)); var propType = new PropertyType(dtd) {Alias = propDef.Alias}; - var prop = new Property(propType, propDef.Value.ToString()); + var prop = new Property(propType, (propDef.Value != null) ? propDef.Value.ToString() : null); var propEditor = PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias); propDef.Value = propEditor.ValueEditor.ConvertDbToString(prop, propType, dataTypeService); } @@ -135,7 +135,7 @@ namespace Archetype.PropertyEditors { var dtd = ArchetypeHelper.Instance.GetDataTypeByGuid(Guid.Parse(propDef.DataTypeGuid)); var propType = new PropertyType(dtd) {Alias = propDef.Alias}; - var prop = new Property(propType, propDef.Value.ToString()); + var prop = new Property(propType, (propDef.Value != null) ? propDef.Value.ToString() : null); var propEditor = PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias); propDef.Value = propEditor.ValueEditor.ConvertDbToEditor(prop, propType, dataTypeService); } @@ -215,7 +215,7 @@ namespace Archetype.PropertyEditors var propData = new ContentPropertyData(propDef.Value, preValues, additionalData); var propEditor = PropertyEditorResolver.Current.GetByAlias(dtd.PropertyEditorAlias); // make sure to send the current property value (if any) to the PE ValueEditor - propDef.Value = propEditor.ValueEditor.ConvertEditorToDb(propData, currentProperty != null ? currentProperty.Value.ToString() : null); + propDef.Value = propEditor.ValueEditor.ConvertEditorToDb(propData, currentProperty != null ? (currentProperty.Value != null) ? currentProperty.Value.ToString() : null : null); } catch (Exception ex) {