From df425383190004b7bcb0230793041e44e2d516f2 Mon Sep 17 00:00:00 2001 From: WarmUpTill <19472752+WarmUpTill@users.noreply.github.com> Date: Fri, 3 Apr 2026 13:21:25 +0200 Subject: [PATCH] Fix temp var values of actions not being accessible This a bug introduced with ec3052c823c23e30c4ec0323999e784ff7bcc9fe. --- lib/macro/macro-segment.cpp | 18 ++++++++++++++++++ lib/macro/macro-segment.hpp | 1 + lib/macro/macro.cpp | 3 +++ 3 files changed, 22 insertions(+) diff --git a/lib/macro/macro-segment.cpp b/lib/macro/macro-segment.cpp index f10907a8..4900c365 100644 --- a/lib/macro/macro-segment.cpp +++ b/lib/macro/macro-segment.cpp @@ -167,6 +167,24 @@ bool MacroSegment::IsTempVarInUse(const std::string &id) const return false; } +void MacroSegment::CopyTempVarValuesFrom(const MacroSegment &other) +{ + for (const auto &src : other._tempVariables) { + for (auto &dst : _tempVariables) { + if (dst.ID() != src.ID()) { + continue; + } + auto value = src.Value(); + if (value) { + dst.SetValue(*value); + } else { + dst.InvalidateValue(); + } + break; + } + } +} + void MacroSegment::SetTempVarValue(const std::string &id, const std::string &value) { diff --git a/lib/macro/macro-segment.hpp b/lib/macro/macro-segment.hpp index 803379d2..b5824b54 100644 --- a/lib/macro/macro-segment.hpp +++ b/lib/macro/macro-segment.hpp @@ -57,6 +57,7 @@ protected: bool IsTempVarInUse(const std::string &id) const; void SetTempVarValue(const std::string &id, const std::string &value); + void CopyTempVarValuesFrom(const MacroSegment &other); template, bool>::value>> diff --git a/lib/macro/macro.cpp b/lib/macro/macro.cpp index cc355e80..e38db3a0 100644 --- a/lib/macro/macro.cpp +++ b/lib/macro/macro.cpp @@ -433,6 +433,9 @@ bool Macro::RunActionsHelper( actionCopy = action->Copy(); }); bool actionResult = actionCopy->PerformAction(); + action->WithLock([&action, &actionCopy]() { + action->CopyTempVarValuesFrom(*actionCopy); + }); actionsExecutedSuccessfully = actionsExecutedSuccessfully && actionResult; } else {