From 577e3504d59f0d8e488ada7a05295d1d8267f095 Mon Sep 17 00:00:00 2001 From: PatTheMav Date: Mon, 24 Feb 2025 20:01:11 +0100 Subject: [PATCH] frontend: Only emit frontend events for existing scene collection To emit frontend events early during OBS' initialization, the disableSaving state variable needs to be "falsy" (as events will not be emitted otherwise). The code path taken for generating a new fallback scene collection has disableSaving decremented to "enable" saving (and thus frontend events) already, so it's just the code paths for existing collections that need this workaround. Emitting the scene changed and preview scene changed events when a fallback scene collection has been created has side-effects when OBS Studio is set to studio mode and can lead to potential crashes, as the studio mode is still in an invalid state at this point. --- frontend/widgets/OBSBasic.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/widgets/OBSBasic.cpp b/frontend/widgets/OBSBasic.cpp index b840930ef..743f717a6 100644 --- a/frontend/widgets/OBSBasic.cpp +++ b/frontend/widgets/OBSBasic.cpp @@ -1035,14 +1035,14 @@ void OBSBasic::OBSInit() disableSaving++; } - disableSaving--; if (foundCollection || configuredCollection) { + disableSaving--; OnEvent(OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED); OnEvent(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED); + OnEvent(OBS_FRONTEND_EVENT_SCENE_CHANGED); + OnEvent(OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED); + disableSaving++; } - OnEvent(OBS_FRONTEND_EVENT_SCENE_CHANGED); - OnEvent(OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED); - disableSaving++; } loaded = true;