修复:避免占位空间被PU

pull/1503/MERGE
ChenX 3 years ago
parent 422469fe82
commit 132b5931af

@ -2,6 +2,7 @@ import { Intent } from "@blueprintjs/core";
import { app } from "../ApplicationServices/Application"; import { app } from "../ApplicationServices/Application";
import { arrayRemoveIf } from "../Common/ArrayExt"; import { arrayRemoveIf } from "../Common/ArrayExt";
import { Database } from "../DatabaseServices/Database"; import { Database } from "../DatabaseServices/Database";
import { Entity } from "../DatabaseServices/Entity/Entity";
import { Command } from "../Editor/CommandMachine"; import { Command } from "../Editor/CommandMachine";
import { TempEditor } from "../Editor/TempEditor"; import { TempEditor } from "../Editor/TempEditor";
import { AppToaster } from "../UI/Components/Toaster"; import { AppToaster } from "../UI/Components/Toaster";
@ -58,15 +59,31 @@ export function Purge(db: Database): void
if (isErase) e.GoodBye(); if (isErase) e.GoodBye();
return isErase; return isErase;
}); });
arrayRemoveIf(db.TemplateTable.Objects, e =>
//应该避免占位空间被PU(占位空间内没有实体,也没有子层)
arrayRemoveIf(db.TemplateTable.Objects, t =>
{ {
if (!e || e.IsErase) return true; if (!t || t.IsErase) return true;
e.Purge();
if (e.AllEntitys.length === 0) let allEnts: Entity[] = [];
t.Traverse(ct =>
{
for (let id of ct.Objects)
{ {
e.Erase(); if (id.Object)
allEnts.push(id.Object as Entity);
}
});
if (allEnts.length && allEnts.every(e => e.IsErase))
{
t.Erase();
t.Traverse(ct => ct.Erase());//PU所有子层
return true; return true;
}; }
//否则PU本层
t.Purge();
}); });
//再次清理,避免子模块没了之后,父模块还引用它 //再次清理,避免子模块没了之后,父模块还引用它

@ -122,6 +122,11 @@ export class TemplateRecord extends SymbolTableRecord
return (<TemplateRecord>this.Parent?.Object)?.Root ?? this; return (<TemplateRecord>this.Parent?.Object)?.Root ?? this;
} }
get IsRoot()
{
return this._Parent === undefined;
}
get Entitys() get Entitys()
{ {
return this.Objects.map(o => o.Object as Entity); return this.Objects.map(o => o.Object as Entity);

@ -676,8 +676,7 @@ export class TemplateParamDetail extends React.Component<{}> {
<> <>
<div className="template-detail-float01"> <div className="template-detail-float01">
{ {
this.store.GetCurrentTemplate() !== this.store.GetCurrentTemplate().Root && !this.store.GetCurrentTemplate().IsRoot && this.RenderPositionRotateionParams()
this.RenderPositionRotateionParams()
} }
</div> </div>
<div className="template-detail-float02"> <div className="template-detail-float02">

Loading…
Cancel
Save