Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在"editing-did-ended"事件中摧毁EditBox所在节点的间接父节点时出错 #17890

Open
mcube-12139 opened this issue Nov 20, 2024 · 1 comment
Labels
Bug Needs Triage Needs to be assigned by the team

Comments

@mcube-12139
Copy link

Cocos Creator version

3.8.4

System information

Windows 10 Editor

Issue description

在EditBox组件所在节点的editing-did-ended事件中摧毁其间接父节点(爷节点)时,产生错误,似乎是一个引擎内部错误。
非必现,但重现概率较高,原因不明。

Relevant error log output

[PreviewInEditor] Cannot read property 'length' of null 
TypeError: Cannot read property 'length' of null 
    at Node._updateSiblingIndex (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin\.cache\dev\editor\bundled\index.js:45101:46) 
    at eval (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin\.cache\dev\editor\bundled\index.js:97958:18) 
    at Map.forEach (<anonymous>) 
    at _sortSiblings (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin\.cache\dev\editor\bundled\index.js:97956:45) 
    at Director.emit (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin\.cache\dev\editor\bundled\index.js:137495:19) 
    at Director.tick (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin\.cache\dev\editor\bundled\index.js:17660:20) 
    at Game._updateCallback (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin\.cache\dev\editor\bundled\index.js:19321:22) 
    at updateCallback (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\resources\3d\engine\bin\.cache\dev\editor\bundled\index.js:78612:20) 
    at sentryWrapped (C:\ProgramData\cocos\editors\Creator\3.8.4\resources\app.asar\node_modules\src\helpers.ts:100:17) 

Steps to reproduce

  1. 新建场景。
  2. 在Canvas节点下创建节点A。
  3. 在节点A下创建节点B。
  4. 在节点B下创建UI Component - EditBox节点。
  5. 创建TypeScript组件NodeControl,写入如下代码:
import { _decorator, Component, EditBox } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('NodeControl')
export class NodeControl extends Component {
    @property(EditBox)
    editBox: EditBox;

    start() {
        this.editBox.node.on("editing-did-ended", (editBox: EditBox) => {
            this.node.destroy();
        }, this);
    }
}
  1. 附加NodeControl组件到节点A上。
  2. 在Inspector中将EditBox节点拖入editBox属性。
  3. 保存,在编辑器中运行预览该场景,在输入框中输入任意内容,然后按下Enter键。

Minimal reproduction project

editbox-bug.zip

@mcube-12139 mcube-12139 added Bug Needs Triage Needs to be assigned by the team labels Nov 20, 2024
@longchuan
Copy link
Contributor

改为this.node.removeFromParent();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Needs to be assigned by the team
Projects
None yet
Development

No branches or pull requests

2 participants