From 5eb8378612e8160d1658af132c6394ec880e902b Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Sun, 23 May 2021 15:51:16 +0200 Subject: [PATCH] Run condition check for paused macros Otherwise conditions might behave in unexpected ways when resuming. For example, audio could immediately match after unpause, when it matched before it was paused due to timers not being updated. --- src/macro.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/macro.cpp b/src/macro.cpp index f8a7d106..f008ad9c 100644 --- a/src/macro.cpp +++ b/src/macro.cpp @@ -20,10 +20,6 @@ Macro::~Macro() {} bool Macro::CeckMatch() { - if (_paused) { - vblog(LOG_INFO, "Macro %s is paused", _name.c_str()); - return false; - } _matched = false; for (auto &c : _conditions) { bool cond = c->CheckCondition(); @@ -64,6 +60,18 @@ bool Macro::CeckMatch() } vblog(LOG_INFO, "Macro %s returned %d", _name.c_str(), _matched); + + // Condition checks shall still be run even if macro is paused. + // Otherwise conditions might behave in unexpected ways when resuming. + // + // For example, audio could immediately match after unpause, when it + // matched before it was paused due to timers not being updated. + if (_paused) { + vblog(LOG_INFO, "Macro %s is paused", _name.c_str()); + _matched = false; + return false; + } + return _matched; }