Skip to content

Commit

Permalink
DisplayObjectContainer: throw error when attempting to add object as …
Browse files Browse the repository at this point in the history
…child to itself

Matches flash target behavior, and makes the issue more clear (instead of freeze/hang)
  • Loading branch information
joshtynjala committed May 29, 2024
1 parent ecdabf3 commit b089565
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/openfl/display/DisplayObjectContainer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ class DisplayObjectContainer extends InteractiveObject
error.errorID = 2007;
throw error;
}
else if (child == this)
{
var error = new ArgumentError("Error #2024: An object cannot be added as a child of itself.");
error.errorID = 2024;
throw error;
}
#if ((haxe_ver >= "3.4.0") || !cpp)
else if (child.stage == child)
{
Expand Down

0 comments on commit b089565

Please sign in to comment.