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 {