| 1250 | size_t moduleIndex; |
| 1251 | json_t* moduleJ; |
| 1252 | json_array_foreach(modulesJ, moduleIndex, moduleJ) { |
| 1253 | // Get model |
| 1254 | plugin::Model* model; |
| 1255 | try { |
| 1256 | model = plugin::modelFromJson(moduleJ); |
| 1257 | } |
| 1258 | catch (Exception& e) { |
| 1259 | WARN("Cannot load model: %s", e.what()); |
| 1260 | // APP->patch->log(e.what()); |
| 1261 | continue; |
| 1262 | } |
| 1263 | |
| 1264 | // Create module |
| 1265 | Module* const module = model->createModule(); |
| 1266 | DISTRHO_SAFE_ASSERT_CONTINUE(module != nullptr); |
| 1267 | |
| 1268 | // Create the widget too, needed by a few modules |
| 1269 | CardinalPluginModelHelper* const helper = dynamic_cast<CardinalPluginModelHelper*>(model); |
| 1270 | DISTRHO_SAFE_ASSERT_CONTINUE(helper != nullptr); |
| 1271 | |
| 1272 | app::ModuleWidget* const moduleWidget = helper->createModuleWidgetFromEngineLoad(module); |
| 1273 | DISTRHO_SAFE_ASSERT_CONTINUE(moduleWidget != nullptr); |
| 1274 | |
| 1275 | try { |
| 1276 | // This doesn't need a lock because the Module is not added to the Engine yet. |
| 1277 | module->fromJson(moduleJ); |
| 1278 | |
| 1279 | // Before 1.0, the module ID was the index in the "modules" array |
| 1280 | if (module->id < 0) { |
| 1281 | module->id = moduleIndex; |
| 1282 | } |
| 1283 | |
| 1284 | // Write-locks |
| 1285 | addModule(module); |
| 1286 | } |
| 1287 | catch (Exception& e) { |
| 1288 | WARN("Cannot load module: %s", e.what()); |
| 1289 | // APP->patch->log(e.what()); |
| 1290 | helper->removeCachedModuleWidget(module); |
| 1291 | delete module; |
| 1292 | continue; |
| 1293 | } |
| 1294 | } |
| 1295 | |
| 1296 | // cables |
| 1297 | json_t* cablesJ = json_object_get(rootJ, "cables"); |
nothing calls this directly
no test coverage detected