mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Fix crash when switching macros after deleting one containing temp refs
This commit is contained in:
parent
8f3b868fd9
commit
b1a5db0c9c
|
|
@ -299,9 +299,17 @@ void TempVariableRef::Save(obs_data_t *obj, Macro *macro,
|
|||
obs_data_set_obj(obj, name, data);
|
||||
}
|
||||
|
||||
void TempVariableRef::Load(obs_data_t *obj, Macro *macro, const char *name)
|
||||
void TempVariableRef::Load(obs_data_t *obj, Macro *macroPtr, const char *name)
|
||||
{
|
||||
if (!macro) {
|
||||
std::weak_ptr<Macro> macro;
|
||||
for (const auto ¯oShared : GetMacros()) {
|
||||
if (macroShared.get() == macroPtr) {
|
||||
macro = macroShared;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (macro.expired()) {
|
||||
_segment.reset();
|
||||
return;
|
||||
}
|
||||
|
|
@ -324,10 +332,17 @@ void TempVariableRef::Load(obs_data_t *obj, Macro *macro, const char *name)
|
|||
});
|
||||
}
|
||||
|
||||
void TempVariableRef::PostLoad(int idx, SegmentType type, Macro *macro)
|
||||
void TempVariableRef::PostLoad(int idx, SegmentType type,
|
||||
const std::weak_ptr<Macro> &weakMacro)
|
||||
{
|
||||
auto childMacro = weakMacro.lock();
|
||||
if (!childMacro) {
|
||||
return;
|
||||
}
|
||||
|
||||
Macro *macro = nullptr;
|
||||
for (int i = 0; i < _depth; i++) {
|
||||
macro = getParentMacro(macro);
|
||||
macro = getParentMacro(childMacro.get());
|
||||
}
|
||||
|
||||
if (!macro) {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ private:
|
|||
enum class SegmentType { NONE, CONDITION, ACTION, ELSEACTION };
|
||||
SegmentType GetType() const;
|
||||
int GetIdx() const;
|
||||
void PostLoad(int idx, SegmentType, Macro *);
|
||||
void PostLoad(int idx, SegmentType, const std::weak_ptr<Macro> &);
|
||||
|
||||
std::string _id = "";
|
||||
std::weak_ptr<MacroSegment> _segment;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user