MCPcopy Create free account
hub / github.com/VCVRack/Rack / load

Method load

src/app/ModuleWidget.cpp:584–600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

582}
583
584void 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
602void ModuleWidget::loadAction(std::string filename) {
603 // history::ModuleChange

Callers

nothing calls this directly

Calls 2

ExceptionClass · 0.85
fromJsonFunction · 0.85

Tested by

no test coverage detected