If videoData is destroyed, remove its eventBus from pageInfo's downstream buses
This commit is contained in:
parent
5a04c2eeee
commit
9648d30aa2
@ -16,6 +16,14 @@ export default class EventBus {
|
||||
this.upstreamBus.addDownstreamBus(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
unsetUpstreamBus(stopRecursing: boolean = false) {
|
||||
if (!stopRecursing) {
|
||||
this.upstreamBus.removeDownstreamBus(this, false);
|
||||
}
|
||||
this.upstreamBus = undefined;
|
||||
}
|
||||
|
||||
addDownstreamBus(eventBus: EventBus, stopRecursing: boolean = false) {
|
||||
if (!this.downstreamBuses.includes(eventBus)) {
|
||||
this.downstreamBuses.push(eventBus);
|
||||
@ -26,6 +34,13 @@ export default class EventBus {
|
||||
}
|
||||
}
|
||||
|
||||
removeDownstreamBus(eventBus: EventBus, stopRecursing: boolean = false) {
|
||||
this.downstreamBuses = this.downstreamBuses.filter(x => x !== eventBus);
|
||||
if (!stopRecursing) {
|
||||
eventBus.unsetUpstreamBus(true);
|
||||
}
|
||||
}
|
||||
|
||||
subscribe(commandString: string, command: EventBusCommand) {
|
||||
if (!this.commands[commandString]) {
|
||||
this.commands[commandString] = [command];
|
||||
|
@ -332,6 +332,7 @@ class VideoData {
|
||||
|
||||
this.disable();
|
||||
this.destroyed = true;
|
||||
this.eventBus?.unsetUpstreamBus();
|
||||
try {
|
||||
this.arDetector.halt();
|
||||
this.arDetector.destroy();
|
||||
|
Loading…
Reference in New Issue
Block a user