From 16bdcc348bf9ed4c236bd6373c65e64ab65e5f75 Mon Sep 17 00:00:00 2001 From: WarmUpTill <19472752+WarmUpTill@users.noreply.github.com> Date: Sun, 23 Aug 2026 18:51:29 +0200 Subject: [PATCH] Fix crash when changing scene collection on MacOS --- .../base/macro-action-scene-collection.cpp | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/plugins/base/macro-action-scene-collection.cpp b/plugins/base/macro-action-scene-collection.cpp index d3f3a6520..c9c69cf72 100644 --- a/plugins/base/macro-action-scene-collection.cpp +++ b/plugins/base/macro-action-scene-collection.cpp @@ -1,7 +1,9 @@ #include "macro-action-scene-collection.hpp" + #include "layout-helpers.hpp" #include "plugin-state-helpers.hpp" #include "selection-helpers.hpp" +#include "ui-helpers.hpp" #include @@ -15,6 +17,20 @@ bool MacroActionSceneCollection::_registered = MacroActionFactory::Register( MacroActionSceneCollectionEdit::Create, "AdvSceneSwitcher.action.sceneCollection"}); +template void QueueUITaskLambda(F &&func) +{ + using FnType = std::decay_t; + auto *heapFunc = new FnType(std::forward(func)); + + QueueUITask( + [](void *param) { + std::unique_ptr fn( + static_cast(param)); + (*fn)(); + }, + heapFunc); +} + bool MacroActionSceneCollection::PerformAction() { // Changing the scene collection will also reload the settings of the @@ -23,7 +39,13 @@ bool MacroActionSceneCollection::PerformAction() if (SettingsWindowIsOpened()) { return false; } - obs_frontend_set_current_scene_collection(_sceneCollection.c_str()); + + const auto collectionName = _sceneCollection; + QueueUITaskLambda([collectionName]() { + obs_frontend_set_current_scene_collection( + collectionName.c_str()); + }); + // It does not make sense to continue as the current settings will be // invalid after switching scene collection. return false;