From d55bb6bc8658599354aa5fb3e528cd75254fb604 Mon Sep 17 00:00:00 2001 From: WarmUpTill <19472752+WarmUpTill@users.noreply.github.com> Date: Wed, 29 Oct 2025 11:11:00 +0100 Subject: [PATCH] Fall back to obs_frontend_get_current_scene() If there wasn't any scene change yet GetCurrentScene() would always return nullptr and break various scene checks. For example, this could happen when startup up a fresh OBS install for the first time. --- lib/utils/scene-switch-helpers.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/utils/scene-switch-helpers.cpp b/lib/utils/scene-switch-helpers.cpp index ba43f355..3a76e14a 100644 --- a/lib/utils/scene-switch-helpers.cpp +++ b/lib/utils/scene-switch-helpers.cpp @@ -199,7 +199,17 @@ std::chrono::high_resolution_clock::time_point GetLastSceneChangeTime() OBSWeakSource GetCurrentScene() { - return switcher->currentScene; + if (switcher->currentScene) { + return switcher->currentScene; + } + + // If there wasn't any scene switch yet switcher->currentScene will be + // null and we must use obs_frontend_get_current_scene() instead + OBSSourceAutoRelease currentSceneSource = + obs_frontend_get_current_scene(); + OBSWeakSourceAutoRelease currentSceneWeakSource = + obs_source_get_weak_source(currentSceneSource); + return currentSceneWeakSource.Get(); } OBSWeakSource GetPreviousScene()