@@ -74,8 +74,11 @@ int main(int argc, char* argv[]) { | |||||
// Parse command line arguments | // Parse command line arguments | ||||
int c; | int c; | ||||
opterr = 0; | opterr = 0; | ||||
while ((c = getopt(argc, argv, "dht:s:u:p:")) != -1) { | |||||
while ((c = getopt(argc, argv, "adht:s:u:p:")) != -1) { | |||||
switch (c) { | switch (c) { | ||||
case 'a': { | |||||
settings::safeMode = true; | |||||
} break; | |||||
case 'd': { | case 'd': { | ||||
settings::devMode = true; | settings::devMode = true; | ||||
} break; | } break; | ||||
@@ -27,6 +27,8 @@ extern bool isPlugin; | |||||
// Persistent state, serialized to settings.json. | // Persistent state, serialized to settings.json. | ||||
/** Launches Rack without loading plugins or the autosave patch. Always set to false when settings are saved. */ | |||||
extern bool safeMode; | |||||
/** vcvrack.com user token */ | /** vcvrack.com user token */ | ||||
extern std::string token; | extern std::string token; | ||||
/** Whether the window is maximized */ | /** Whether the window is maximized */ | ||||
@@ -47,6 +47,10 @@ void Manager::launch(std::string pathArg) { | |||||
return; | return; | ||||
} | } | ||||
// Don't load autosave or template if safe mode is enabled | |||||
if (settings::safeMode) | |||||
return; | |||||
// Try loading the autosave patch | // Try loading the autosave patch | ||||
if (hasAutosave()) { | if (hasAutosave()) { | ||||
try { | try { | ||||
@@ -256,6 +256,10 @@ void init() { | |||||
// Get user plugins directory | // Get user plugins directory | ||||
system::createDirectory(pluginsPath); | system::createDirectory(pluginsPath); | ||||
// Don't load plugins if safe mode is enabled | |||||
if (settings::safeMode) | |||||
return; | |||||
// Extract packages and load plugins | // Extract packages and load plugins | ||||
extractPackages(pluginsPath); | extractPackages(pluginsPath); | ||||
loadPlugins(pluginsPath); | loadPlugins(pluginsPath); | ||||
@@ -19,6 +19,7 @@ bool devMode = false; | |||||
bool headless = false; | bool headless = false; | ||||
bool isPlugin = false; | bool isPlugin = false; | ||||
bool safeMode = false; | |||||
std::string token; | std::string token; | ||||
bool windowMaximized = false; | bool windowMaximized = false; | ||||
math::Vec windowSize = math::Vec(1024, 720); | math::Vec windowSize = math::Vec(1024, 720); | ||||
@@ -107,6 +108,9 @@ void destroy() { | |||||
json_t* toJson() { | json_t* toJson() { | ||||
json_t* rootJ = json_object(); | json_t* rootJ = json_object(); | ||||
// Always disable safe mode when settings are saved. | |||||
json_object_set_new(rootJ, "safeMode", json_boolean(false)); | |||||
json_object_set_new(rootJ, "token", json_string(token.c_str())); | json_object_set_new(rootJ, "token", json_string(token.c_str())); | ||||
json_object_set_new(rootJ, "windowMaximized", json_boolean(windowMaximized)); | json_object_set_new(rootJ, "windowMaximized", json_boolean(windowMaximized)); | ||||
@@ -241,6 +245,13 @@ json_t* toJson() { | |||||
} | } | ||||
void fromJson(json_t* rootJ) { | void fromJson(json_t* rootJ) { | ||||
json_t* safeModeJ = json_object_get(rootJ, "safeMode"); | |||||
if (safeModeJ) { | |||||
// If safe mode is enabled (e.g. by command line flag), don't disable it when loading. | |||||
if (json_boolean_value(safeModeJ)) | |||||
safeMode = true; | |||||
} | |||||
json_t* tokenJ = json_object_get(rootJ, "token"); | json_t* tokenJ = json_object_get(rootJ, "token"); | ||||
if (tokenJ) | if (tokenJ) | ||||
token = json_string_value(tokenJ); | token = json_string_value(tokenJ); | ||||