From 787bd1a532dc7f3aa4edb17a2a3535d3940ffd1b Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Mon, 1 Nov 2021 01:18:07 +0100 Subject: [PATCH] Prevent eventBus from crashing everything under certain conditions --- src/csui/PlayerUiPanels/VideoSettings.vue | 10 ++-------- src/ext/lib/EventBus.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/csui/PlayerUiPanels/VideoSettings.vue b/src/csui/PlayerUiPanels/VideoSettings.vue index b2f029d..5209171 100644 --- a/src/csui/PlayerUiPanels/VideoSettings.vue +++ b/src/csui/PlayerUiPanels/VideoSettings.vue @@ -155,8 +155,8 @@ export default { CropModePersistence: CropModePersistence, zoomAspectRatioLocked: true, zoom: { - x: 1, - y: 1 + x: 0, + y: 0 } } }, @@ -209,17 +209,11 @@ export default { resetZoom() { this.zoom = 1; this.eventBus.send('set-zoom', {zoom: 1}); - - console.log('resetting zoom!'); - }, changeZoom(newZoom, axis) { newZoom = Math.pow(2, newZoom); - console.log('new zoom:', newZoom); this.eventBus.send('set-zoom', {zoom: newZoom, axis: axis, noAnnounce: true}); - - // this.zoom = newZoom; }, } } diff --git a/src/ext/lib/EventBus.ts b/src/ext/lib/EventBus.ts index b1a7456..9f26d74 100644 --- a/src/ext/lib/EventBus.ts +++ b/src/ext/lib/EventBus.ts @@ -20,6 +20,11 @@ export default class EventBus { } send(command: string, config: any, stopPropagation?: boolean) { + if (!this.commands ||!this.commands[command]) { + // ensure send is not being called for commands that we have no subscriptions for + return; + } + for (const eventBusCommand of this.commands[command]) { eventBusCommand.function(config); @@ -31,6 +36,11 @@ export default class EventBus { } sendGlobal(command: string, config: any) { + if (!this.commands ||!this.commands[command]) { + // ensure send is not being called for commands that we have no subscriptions for + return; + } + for (const eventBusCommand of this.commands[command]) { this.sendUpstream(command, config); this.sendDownstream(command, config);