summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Belt <andrewpbelt@gmail.com>2024-04-15 19:04:46 -0400
committerAndrew Belt <andrewpbelt@gmail.com>2024-04-15 19:04:46 -0400
commit6c18b05ac7d779bc4b9dccbf264e04023be63169 (patch)
treecc3c648bd515f4d391558281186677a914d9234f
parent8b12a18f0de90afe9b4e36494303b3a4162626f0 (diff)
If loaded patch contains unavailable modules, after informing user, don't close Rack. Instead, load patch anyway.
-rw-r--r--include/patch.hpp4
-rw-r--r--src/patch.cpp32
2 files changed, 17 insertions, 19 deletions
diff --git a/include/patch.hpp b/include/patch.hpp
index 89ef4526..89a43903 100644
--- a/include/patch.hpp
+++ b/include/patch.hpp
@@ -46,7 +46,9 @@ struct Manager {
void loadTemplate();
void loadTemplateDialog();
bool hasAutosave();
- /** Loads the patch from the autosave folder. */
+ /** Loads the patch from the autosave folder.
+ Throws if loading failed.
+ */
void loadAutosave();
/** Loads a patch, sets the current path, and updates the recent patches. */
void loadAction(std::string path);
diff --git a/src/patch.cpp b/src/patch.cpp
index 724c6418..1784eddf 100644
--- a/src/patch.cpp
+++ b/src/patch.cpp
@@ -24,7 +24,6 @@ static const char PATCH_FILTERS[] = "VCV Rack patch (.vcv):vcv";
struct Manager::Internal {
- bool disableAutosaveOnClose = false;
};
@@ -51,15 +50,13 @@ Manager::~Manager() {
return;
}
- if (!internal->disableAutosaveOnClose) {
- // Dispatch onSave to all Modules so they save their patch storage, etc.
- APP->engine->prepareSave();
- // Save autosave if not headless
- if (!settings::headless) {
- APP->patch->saveAutosave();
- }
- cleanAutosave();
+ // Dispatch onSave to all Modules so they save their patch storage, etc.
+ APP->engine->prepareSave();
+ // Save autosave if not headless
+ if (!settings::headless) {
+ APP->patch->saveAutosave();
}
+ cleanAutosave();
delete internal;
}
@@ -360,8 +357,7 @@ void Manager::loadAutosave() {
throw Exception("Failed to load patch. JSON parsing error at %s %d:%d %s", error.source, error.line, error.column, error.text);
DEFER({json_decref(rootJ);});
- if (checkUnavailableModulesJson(rootJ))
- return;
+ checkUnavailableModulesJson(rootJ);
fromJson(rootJ);
}
@@ -573,18 +569,18 @@ bool Manager::checkUnavailableModulesJson(json_t* rootJ) {
}
if (!pluginModuleSlugs.empty()) {
- std::string msg = "This patch includes modules that are not installed. Close Rack and show missing modules on the VCV Library?";
+ // Ask user to open browser
+ std::string msg = "This patch includes modules that are not installed:";
+ msg += "\n\n";
+ msg += string::join(pluginModuleSlugs, "\n");
+ msg += "\n\n";
+ msg += "Show missing modules on the VCV Library?";
if (osdialog_message(OSDIALOG_WARNING, OSDIALOG_YES_NO, msg.c_str())) {
std::string url = "https://library.vcvrack.com/?modules=";
url += string::join(pluginModuleSlugs, ",");
system::openBrowser(url);
- // Close Rack
- APP->window->close();
- // Don't save autosave when closing
- // Possible bug: The autosave internal could still occur before the window closes
- internal->disableAutosaveOnClose = true;
- return true;
}
+ return true;
}
return false;
}