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

change order of removal of objects children (allow self removal on onRemove without leak)

Nicolas Cannasse 3 роки тому
батько
коміт
7f3a66aa95
2 змінених файлів з 6 додано та 4 видалено
  1. 3 2
      h2d/Object.hx
  2. 3 2
      h3d/scene/Object.hx

+ 3 - 2
h2d/Object.hx

@@ -488,8 +488,9 @@ class Object #if (domkit && !domkit_heaps) implements domkit.Model<h2d.Object> #
 		allocated = false;
 		if( filter != null )
 			filter.unbind(this);
-		for( c in children )
-			c.onRemove();
+		var i = children.length - 1;
+		while( i >= 0 )
+			children[i--].onRemove();
 	}
 
 	/**

+ 3 - 2
h3d/scene/Object.hx

@@ -528,8 +528,9 @@ class Object {
 	// kept for internal cleanup
 	function onRemove() {
 		allocated = false;
-		for( c in children )
-			c.onRemove();
+		var i = children.length - 1;
+		while( i >= 0 )
+			children[i--].onRemove();
 	}
 
 	/**