From 1cf6b3d45ea2455f37c35a4a72e9842dc67df798 Mon Sep 17 00:00:00 2001 From: PatTheMav Date: Sat, 26 Oct 2024 22:18:17 +0200 Subject: [PATCH] UI: Restore frontend API events being dispatched during initialization The frontend API events "OBS_FRONTEND_EVENT_SCENE_CHANGED" and "OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED" are not dispatched if disableSaving has a value > 0. Prior code decremented disableSaving to 0 globally (regardless of whether saving was necessary, which is only the case if a new collection is created as a fallback for a missing scene collection). Thus the updated code exhibits different event dispatch behavior then old code which some plugins might have relied on. To avoid introducing new behavior, explicitly create the environment to allow the dispatch to take place and remove/refactor the events in a later version. --- UI/window-basic-main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 34a7bb231..5924408ae 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -2192,6 +2192,15 @@ void OBSBasic::OBSInit() SetupNewSceneCollection(sceneCollectionName); disableSaving++; } + + disableSaving--; + if (foundCollection || configuredCollection) { + 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++; } loaded = true;