Browse Source

Fixing errors with orphan SubObjects.

Kenric Nugteren 9 tháng trước cách đây
mục cha
commit
01c842e298
2 tập tin đã thay đổi với 6 bổ sung6 xóa
  1. 5 5
      InABox.Core/EnclosedEntity.cs
  2. 1 1
      InABox.Core/EntityLink.cs

+ 5 - 5
InABox.Core/EnclosedEntity.cs

@@ -11,9 +11,9 @@ namespace InABox.Core
     public abstract class EnclosedEntity : BaseObject, IEnclosedEntity
     {
 
-        private BaseObject _linkedParent;
+        private BaseObject? _linkedParent;
 
-        private string _linkedPath;
+        private string? _linkedPath;
 
         public void SetLinkedParent(BaseObject parent)
         {
@@ -35,13 +35,13 @@ namespace InABox.Core
             return new SubObjectLoadedColumns(this);
         }
 
-        public BaseObject GetLinkedParent() => _linkedParent;
+        public BaseObject? GetLinkedParent() => _linkedParent;
 
-        public string GetLinkedPath() => _linkedPath;
+        public string? GetLinkedPath() => _linkedPath;
         
         protected override void DoPropertyChanged(string name, object? before, object? after)
         {
-            LinkedProperties.GetParent(this).CascadePropertyChanged(LinkedProperties.GetPath(this) + "." + name, before, after);
+            LinkedProperties.GetParent(this)?.CascadePropertyChanged(LinkedProperties.GetPath(this) + "." + name, before, after);
 
             if (LinkedProperties.Find(this, name, out var link, out var parent))
             {

+ 1 - 1
InABox.Core/EntityLink.cs

@@ -144,7 +144,7 @@ namespace InABox.Core
 
         protected override void DoPropertyChanged(string name, object? before, object? after)
         {
-            LinkedProperties.GetParent(this).CascadePropertyChanged(LinkedProperties.GetPath(this) + "." + name, before, after);
+            LinkedProperties.GetParent(this)?.CascadePropertyChanged(LinkedProperties.GetPath(this) + "." + name, before, after);
 
             if (LinkedProperties.Find(this, name, out var link, out var parent))
             {