diff --git a/src/patch.cpp b/src/patch.cpp index 861e0aa4..ec468e6a 100644 --- a/src/patch.cpp +++ b/src/patch.cpp @@ -155,14 +155,19 @@ void Manager::saveDialog() { void Manager::saveAsDialog(bool setPath) { std::string dir; std::string filename; - if (this->path == "") { + if (this->path != "") { + dir = system::getDirectory(this->path); + filename = system::getFilename(this->path); + } + + // Default to /patches + if (dir == "" || !system::isDirectory(dir)) { dir = asset::user("patches"); system::createDirectories(dir); - filename = "Untitled.vcv"; } - else { - dir = system::getDirectory(this->path); - filename = system::getFilename(this->path); + + if (filename == "") { + filename = "Untitled.vcv"; } osdialog_filters* filters = osdialog_filters_parse(PATCH_FILTERS); @@ -384,13 +389,15 @@ void Manager::loadDialog() { return; std::string dir; - if (this->path == "") { + if (this->path != "") { + dir = system::getDirectory(this->path); + } + + // Default to /patches + if (dir == "" || !system::isDirectory(dir)) { dir = asset::user("patches"); system::createDirectory(dir); } - else { - dir = system::getDirectory(this->path); - } osdialog_filters* filters = osdialog_filters_parse(PATCH_FILTERS); DEFER({osdialog_filters_free(filters);});