fix(ui):keep destroy widgets out of the widget's active list (#302)

This commit is contained in:
ChiaNing
2026-08-21 10:04:48 +08:00
committed by GitHub
parent 09b63786f4
commit 609512f8da
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -204,7 +204,7 @@ function align (node: Node, widget: Widget): void {
// TODO: type is hack, Change to the type actually used (Node or BaseNode) when BaseNode complete
function visitNode (node: any): void {
const widget = node.getComponent(Widget);
if (widget && widget.enabled) {
if (widget && widget.enabled && cclegacy.isValid(widget, true)) {
if (DEV) {
widget._validateTargetInDEV();
}
+3
View File
@@ -852,6 +852,9 @@ export class Widget extends Component {
}
public onDestroy (): void {
// `onDisable` is skipped when the component was never enabled by the scheduler
// (`IsOnEnableCalled` unset), so unregister here as well.
cclegacy._widgetManager?.remove(this);
this._removeParentEvent();
}