Skip to content

Commit

Permalink
fix(front): correct outliner disposal
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Oct 14, 2024
1 parent 20d2c59 commit 7c57c46
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/front/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@thatopen/components-front",
"description": "Collection of frontend tools to author BIM apps.",
"version": "2.3.4",
"version": "2.3.5",
"author": "That Open Company",
"contributors": [
"Antonio Gonzalez Viegas (https://github.com/agviegas)",
Expand Down
6 changes: 6 additions & 0 deletions packages/front/src/fragments/Highlighter/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ stats.dom.style.zIndex = "unset";
world.renderer.onBeforeUpdate.add(() => stats.begin());
world.renderer.onAfterUpdate.add(() => stats.end());

window.addEventListener("keydown", (e) => {
if(e.code === "KeyP") {
components.dispose();
}
})

/* MD
### 🎉 Wrap up
---
Expand Down
14 changes: 8 additions & 6 deletions packages/front/src/fragments/Outliner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export class Outliner extends OBC.Component implements OBC.Disposable {

/** {@link OBC.Component.enabled} */
set enabled(value: boolean) {
if (!this.world) {
throw new Error("Before enabling the outliner, provide a world!");
if (!this.world || this.world.isDisposing) {
return;
}

const renderer = this.getRenderer();
Expand Down Expand Up @@ -123,10 +123,12 @@ export class Outliner extends OBC.Component implements OBC.Disposable {
/** {@link OBC.Disposable.dispose} */

dispose() {
const styles = this.getStyles();
const styleNames = Object.keys(styles);
for (const name of styleNames) {
this.clearStyle(name, true);
if (this.world && !this.world.isDisposing) {
const styles = this.getStyles();
const styleNames = Object.keys(styles);
for (const name of styleNames) {
this.clearStyle(name, true);
}
}
this.onDisposed.trigger();
this.onDisposed.reset();
Expand Down

0 comments on commit 7c57c46

Please sign in to comment.