-
-
Notifications
You must be signed in to change notification settings - Fork 395
Description
Describe the bug
When setting a node's parent via the parent property, the _isRoot flag of the child node is not updated to false. This omission causes an infinite loop when invoking parent.destroy(), as the child node incorrectly retains its _isRoot status, leading to circular references during destruction.
To Reproduce
Steps to reproduce the behavior:
WebGLEngine.create({ canvas: 'canvas' })
.then(engine => {
engine.canvas.resizeByClientSize();
const scene = engine.sceneManager.activeScene;
const parent = scene.createRootEntity('parentEntity');
const child = scene.createRootEntity('childEntity');
parent.addChild(child);
console.log('set parent by addChild, isRoot: ', child._isRoot);
scene.addRootEntity(child);
console.log('set root: ', child.parent, parent.children);
child.parent = parent;
console.log('set parent by set property, isRoot ', child._isRoot);
scene.addRootEntity(child);
console.log('set root: ', child.parent, parent.children);
parent.destroy();
engine.run();
});Expected behavior
The child node's _isRoot flag should automatically be set to false when assigned a parent.
parent.destroy() should clean up all child references without entering an infinite loop.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context
Add any other context about the problem here.