mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-05-24 08:47:30 -05:00
Fix temp var mapping not working after copy-paste of segment
This commit is contained in:
parent
529bc8ad8b
commit
8109a3ffd0
|
|
@ -57,6 +57,8 @@ void MacroEdit::PasteMacroSegment()
|
|||
OBSDataAutoRelease data = obs_data_create();
|
||||
copyInfo.segment->Save(data);
|
||||
|
||||
const MacroSegment *const original = copyInfo.segment.get();
|
||||
|
||||
switch (copyInfo.type) {
|
||||
case MacroSegmentCopyInfo::Type::CONDITION: {
|
||||
const auto condition = std::static_pointer_cast<MacroCondition>(
|
||||
|
|
@ -72,15 +74,26 @@ void MacroEdit::PasteMacroSegment()
|
|||
}
|
||||
AddMacroCondition(macro.get(), macro->Conditions().size(),
|
||||
copyInfo.segment->GetId(), data.Get(), logic);
|
||||
if (!macro->Conditions().empty()) {
|
||||
macro->Conditions().back()->FixupVarMappingRefs(
|
||||
original);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MacroSegmentCopyInfo::Type::ACTION:
|
||||
AddMacroAction(macro.get(), macro->Actions().size(),
|
||||
copyInfo.segment->GetId(), data.Get());
|
||||
if (!macro->Actions().empty()) {
|
||||
macro->Actions().back()->FixupVarMappingRefs(original);
|
||||
}
|
||||
break;
|
||||
case MacroSegmentCopyInfo::Type::ELSE:
|
||||
AddMacroElseAction(macro.get(), macro->ElseActions().size(),
|
||||
copyInfo.segment->GetId(), data.Get());
|
||||
if (!macro->ElseActions().empty()) {
|
||||
macro->ElseActions().back()->FixupVarMappingRefs(
|
||||
original);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,22 @@ void MacroSegment::SetVarMappings(const std::vector<VarMapping> &mappings)
|
|||
_varMappings = mappings;
|
||||
}
|
||||
|
||||
void MacroSegment::FixupVarMappingRefs(const MacroSegment *originalSegment)
|
||||
{
|
||||
for (auto &mapping : _varMappings) {
|
||||
auto refSeg = mapping.tempVar._segment.lock();
|
||||
if (refSeg.get() != originalSegment) {
|
||||
continue;
|
||||
}
|
||||
for (const auto &var : _tempVariables) {
|
||||
if (var.ID() == mapping.tempVar._id) {
|
||||
mapping.tempVar = var.GetRef();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<TempVariable> MacroSegment::GetOwnTempVars() const
|
||||
{
|
||||
return _tempVariables;
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ public:
|
|||
const std::vector<VarMapping> &GetVarMappings() const;
|
||||
void SetVarMappings(const std::vector<VarMapping> &mappings);
|
||||
std::vector<TempVariable> GetOwnTempVars() const;
|
||||
void FixupVarMappingRefs(const MacroSegment *originalSegment);
|
||||
|
||||
protected:
|
||||
friend bool SupportsVariableValue(MacroSegment *);
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ private:
|
|||
|
||||
friend TempVariable;
|
||||
friend TempVariableSelection;
|
||||
friend MacroSegment;
|
||||
};
|
||||
|
||||
class ADVSS_EXPORT TempVariableSelection : public QWidget {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user