fix(sdk): capture loader ref in unpackGroup to prevent race condition on done() cleanup

This commit is contained in:
plum 2026-04-10 02:09:08 +08:00
parent e78afc73f3
commit 6720a3e730

View File

@ -1337,6 +1337,9 @@ export class Package {
//const db = window.VIEWPORT.modules["db"]; //const db = window.VIEWPORT.modules["db"];
//const dbTable = `${useProjectState.getState().sceneId}-${useProjectState.getState().info.id}`; //const dbTable = `${useProjectState.getState().sceneId}-${useProjectState.getState().info.id}`;
// 在调用时捕获 loader 引用,防止 done() 清除 this.loader 后重试路径报错
const loader = this.loader;
// map 存储 json 解析完成后执行的 function; key 为 uuid // map 存储 json 解析完成后执行的 function; key 为 uuid
const funcMap = new Map<string, Function>(); const funcMap = new Map<string, Function>();
@ -1433,7 +1436,8 @@ export class Package {
const parse = (json) => { const parse = (json) => {
if (check(json.object, json)) { if (check(json.object, json)) {
this.loader.parse(json, (group) => { if (!loader) return;
loader.parse(json, (group) => {
const bones: Bone[] = []; const bones: Bone[] = [];
group.getObjectsByProperty("type", "Bone", bones); group.getObjectsByProperty("type", "Bone", bones);
if (bones.length > 0) { if (bones.length > 0) {