From fbc98187649dfca4fcc718b2f8b5899626446a55 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Thu, 11 Nov 2021 21:59:14 +0100 Subject: [PATCH] Fix macro count not updating correctly The underlying issue are the potential deadlocks when triggering frontent function calls while saving / loading is triggered in parallel like it can happen when switching scene collections. Hopefully the new frontend events allow for a cleaner solution. --- src/macro.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/macro.cpp b/src/macro.cpp index 48a2d5ff..05333ea1 100644 --- a/src/macro.cpp +++ b/src/macro.cpp @@ -93,6 +93,14 @@ bool Macro::CeckMatch() } vblog(LOG_INFO, "Macro %s returned %d", _name.c_str(), _matched); + + // TODO: Move back to PerformAction() once new scene collection frontend + // events are available - see: + // https://github.com/obsproject/obs-studio/commit/feda1aaa283e8a99f6ba1159cfe6b9c1f2934a61 + if (_matched && _count != std::numeric_limits::max()) { + _count++; + } + return _matched; } @@ -106,9 +114,6 @@ bool Macro::PerformAction() return false; } } - if (_count != std::numeric_limits::max()) { - _count++; - } return ret; } @@ -500,6 +505,9 @@ bool SwitcherData::checkMacros() bool SwitcherData::runMacros() { + // TODO: Don't rely on creating a copy of each macro once new frontend + // events are available - see: + // https://github.com/obsproject/obs-studio/commit/feda1aaa283e8a99f6ba1159cfe6b9c1f2934a61 for (auto m : macros) { if (m.Matched()) { vblog(LOG_INFO, "running macro: %s", m.Name().c_str());