mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Detect invalid group setups and attempt to clean them up
This commit is contained in:
parent
7ae88f7560
commit
64ccd5ba53
|
|
@ -709,18 +709,41 @@ void SwitcherData::loadMacros(obs_data_t *obj)
|
|||
obs_data_array_release(macroArray);
|
||||
|
||||
int groupCount = 0;
|
||||
Macro *group = nullptr;
|
||||
std::shared_ptr<Macro> group;
|
||||
std::vector<std::shared_ptr<Macro>> invalidGroups;
|
||||
for (auto &m : macros) {
|
||||
if (groupCount && m->IsGroup()) {
|
||||
blog(LOG_ERROR,
|
||||
"nested group detected - will delete \"%s\"",
|
||||
m->Name().c_str());
|
||||
invalidGroups.emplace_back(m);
|
||||
continue;
|
||||
}
|
||||
if (groupCount) {
|
||||
m->SetParent(group);
|
||||
m->SetParent(group.get());
|
||||
groupCount--;
|
||||
}
|
||||
if (m->IsGroup()) {
|
||||
groupCount = m->GroupSize();
|
||||
group = m.get();
|
||||
group = m;
|
||||
}
|
||||
m->PostLoad();
|
||||
}
|
||||
|
||||
if (groupCount) {
|
||||
blog(LOG_ERROR,
|
||||
"invalid group size detected - will delete \"%s\"",
|
||||
group->Name().c_str());
|
||||
invalidGroups.emplace_back(group);
|
||||
}
|
||||
|
||||
for (auto &m : invalidGroups) {
|
||||
auto it = std::find(macros.begin(), macros.end(), m);
|
||||
if (it == macros.end()) {
|
||||
continue;
|
||||
}
|
||||
macros.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
bool SwitcherData::checkMacros()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user