| 582 | } |
| 583 | |
| 584 | void ModuleWidget::load(std::string filename) { |
| 585 | FILE* file = std::fopen(filename.c_str(), "r"); |
| 586 | if (!file) |
| 587 | throw Exception("Could not load patch file %s", filename.c_str()); |
| 588 | DEFER({std::fclose(file);}); |
| 589 | |
| 590 | INFO("Loading preset %s", filename.c_str()); |
| 591 | |
| 592 | json_error_t error; |
| 593 | json_t* moduleJ = json_loadf(file, 0, &error); |
| 594 | if (!moduleJ) |
| 595 | throw Exception("File is not a valid patch file. JSON parsing error at %s %d:%d %s", error.source, error.line, error.column, error.text); |
| 596 | DEFER({json_decref(moduleJ);}); |
| 597 | |
| 598 | engine::Module::jsonStripIds(moduleJ); |
| 599 | fromJson(moduleJ); |
| 600 | } |
| 601 | |
| 602 | void ModuleWidget::loadAction(std::string filename) { |
| 603 | // history::ModuleChange |