Skip to content

Commit

Permalink
prevent unit removal on parent graph destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
io-sammt authored and samuelmtimbo committed Oct 11, 2024
1 parent 273530c commit f2505d7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Class/Graph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,11 @@ export class Graph<I extends Dict<any> = any, O extends Dict<any> = any>
private _destroy = () => {
this._spec = clone(this._spec)

this._destroying = true

forEachValueKey(this._unit, (u) => u.destroy())

this._destroying = false
}

private _reset = (): void => {
Expand Down Expand Up @@ -3782,6 +3786,10 @@ export class Graph<I extends Dict<any> = any, O extends Dict<any> = any>

all_unlisten.push(
unit.addListener('destroy', () => {
if (this._destroying) {
return
}

if (this._removingUnit.has(unitId)) {
return
}
Expand Down Expand Up @@ -4077,6 +4085,8 @@ export class Graph<I extends Dict<any> = any, O extends Dict<any> = any>

private _removingUnit: Set<string> = new Set()

private _destroying: boolean

private _removeUnit(
unitId: string,
take: boolean = true,
Expand Down

0 comments on commit f2505d7

Please sign in to comment.