mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-19 14:52:40 +08:00
fix(ui):keep destroy widgets out of the widget's active list (#302)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user