MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / LoadMacros

Function LoadMacros

lib/macro/macro.cpp:1203–1255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1201}
1202
1203void LoadMacros(obs_data_t *obj)
1204{
1205 auto &macros = GetTopLevelMacros();
1206 macros.clear();
1207
1208 obs_data_array_t *macroArray = obs_data_get_array(obj, "macros");
1209 size_t count = obs_data_array_count(macroArray);
1210
1211 for (size_t i = 0; i < count; i++) {
1212 obs_data_t *array_obj = obs_data_array_item(macroArray, i);
1213 macros.emplace_back(std::make_shared<Macro>());
1214 macros.back()->Load(array_obj);
1215 obs_data_release(array_obj);
1216 }
1217 obs_data_array_release(macroArray);
1218
1219 int groupCount = 0;
1220 std::shared_ptr<Macro> group;
1221 std::vector<std::shared_ptr<Macro>> invalidGroups;
1222 for (const auto &m : macros) {
1223 if (groupCount && m->IsGroup()) {
1224 blog(LOG_ERROR,
1225 "nested group detected - will delete \"%s\"",
1226 m->Name().c_str());
1227 invalidGroups.emplace_back(m);
1228 continue;
1229 }
1230 if (groupCount) {
1231 m->SetParent(group);
1232 groupCount--;
1233 }
1234 if (m->IsGroup()) {
1235 groupCount = m->GroupSize();
1236 group = m;
1237 }
1238 m->PostLoad();
1239 }
1240
1241 if (groupCount) {
1242 blog(LOG_ERROR,
1243 "invalid group size detected - will delete \"%s\"",
1244 group->Name().c_str());
1245 invalidGroups.emplace_back(group);
1246 }
1247
1248 for (auto &m : invalidGroups) {
1249 auto it = std::find(macros.begin(), macros.end(), m);
1250 if (it == macros.end()) {
1251 continue;
1252 }
1253 macros.erase(it);
1254 }
1255}
1256
1257bool CheckMacros()
1258{

Callers 1

LoadSettingsMethod · 0.85

Calls 9

IsGroupMethod · 0.80
SetParentMethod · 0.80
GroupSizeMethod · 0.80
LoadMethod · 0.45
c_strMethod · 0.45
NameMethod · 0.45
PostLoadMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected