From 4637027f890b2cd28dc756fe5d26177231c041d8 Mon Sep 17 00:00:00 2001 From: Core447 Date: Tue, 26 Mar 2024 19:08:18 +0100 Subject: [PATCH] Fix: Possible crash if backend needs too long to start --- actions/RecPlayPause/RecPlayPause.py | 7 ++++--- actions/SwitchScene/SwitchScene.py | 5 +++-- actions/ToggleRecord/ToggleRecord.py | 5 +++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/actions/RecPlayPause/RecPlayPause.py b/actions/RecPlayPause/RecPlayPause.py index b8c18df..7ce2d03 100644 --- a/actions/RecPlayPause/RecPlayPause.py +++ b/actions/RecPlayPause/RecPlayPause.py @@ -13,9 +13,10 @@ class RecPlayPause(OBSActionBase): def on_ready(self): # Connect to obs if not connected - if not self.plugin_base.backend.get_connected(): - # self.plugin_base.obs.connect_to(host="localhost", port=4444, timeout=3, legacy=False) - self.reconnect_obs() + if self.plugin_base.backend is not None: + if not self.plugin_base.backend.get_connected(): + # self.plugin_base.obs.connect_to(host="localhost", port=4444, timeout=3, legacy=False) + self.reconnect_obs() # Show current rec status self.show_current_rec_status() diff --git a/actions/SwitchScene/SwitchScene.py b/actions/SwitchScene/SwitchScene.py index 5f1b0e8..7a4e2bb 100644 --- a/actions/SwitchScene/SwitchScene.py +++ b/actions/SwitchScene/SwitchScene.py @@ -20,8 +20,9 @@ class SwitchScene(OBSActionBase): def on_ready(self): # Connect to obs if not connected - if not self.plugin_base.backend.get_connected(): # self.plugin_base.obs.connect_to(host="localhost", port=4444, timeout=3, legacy=False) - self.reconnect_obs() + if self.plugin_base.backend is not None: + if not self.plugin_base.backend.get_connected(): # self.plugin_base.obs.connect_to(host="localhost", port=4444, timeout=3, legacy=False) + self.reconnect_obs() media_path = os.path.join(self.plugin_base.PATH, "assets", "transition_slide.png") self.set_media(media_path=media_path, size=0.75) diff --git a/actions/ToggleRecord/ToggleRecord.py b/actions/ToggleRecord/ToggleRecord.py index 71dfc4a..e94a45b 100644 --- a/actions/ToggleRecord/ToggleRecord.py +++ b/actions/ToggleRecord/ToggleRecord.py @@ -14,8 +14,9 @@ class ToggleRecord(OBSActionBase): def on_ready(self): # Connect to obs if not connected - if not self.plugin_base.backend.get_connected(): # self.plugin_base.obs.connect_to(host="localhost", port=4444, timeout=3, legacy=False) - self.reconnect_obs() + if self.plugin_base.backend is not None: + if not self.plugin_base.backend.get_connected(): # self.plugin_base.obs.connect_to(host="localhost", port=4444, timeout=3, legacy=False) + self.reconnect_obs() # Show current rec status self.show_current_rec_status()