Переглянути джерело

Fixed single child setter

Vicente Penades Armengot 10 місяців тому
батько
коміт
f2d62e341e

+ 2 - 4
src/SharpGLTF.Core/Collections/ChildSetter.cs

@@ -38,13 +38,11 @@ namespace SharpGLTF.Collections
             if (Object.ReferenceEquals(value , target)) return;
 
             // orphan the current child
-
-            if (target is IChildOf<TParent> oldChild) oldChild.SetLogicalParent(null);
-            target = null;
+            if (target is IChildOf<TParent> oldChild) oldChild.SetLogicalParent(null);            
 
             // adopt the new child
             target = value;
-            if (target is IChildOf<TParent> newChild) newChild.SetLogicalParent(null);
+            if (target is IChildOf<TParent> newChild) newChild.SetLogicalParent(_Parent);
         }
 
         #endregion

+ 2 - 2
tests/SharpGLTF.ThirdParty.Tests/MeltyPlayerTests.cs

@@ -95,7 +95,7 @@ namespace SharpGLTF.ThirdParty
 
             MemoryImage diffuseImage, occlusionImage;
             {
-                var img = new Bitmap(diffuseImageSize, diffuseImageSize, PixelFormat.Format32bppArgb);
+                using var img = new Bitmap(diffuseImageSize, diffuseImageSize, PixelFormat.Format32bppArgb);
 
                 using var mem = new MemoryStream();
                 img.Save(mem, ImageFormat.Png);
@@ -104,7 +104,7 @@ namespace SharpGLTF.ThirdParty
                 diffuseImage = new MemoryImage(bytes);
             }
             {
-                var img = new Bitmap(occlusionImageSize, occlusionImageSize, PixelFormat.Format32bppArgb);
+                using var img = new Bitmap(occlusionImageSize, occlusionImageSize, PixelFormat.Format32bppArgb);
 
                 using var mem = new MemoryStream();
                 img.Save(mem, ImageFormat.Png);