Browse Source

Use default patch dir in open/save dialogs if current patch dir doesn't exist.

tags/v2.5.2
Andrew Belt 6 months ago
parent
commit
7545ada7e3
1 changed files with 16 additions and 9 deletions
  1. +16
    -9
      src/patch.cpp

+ 16
- 9
src/patch.cpp View File

@@ -155,14 +155,19 @@ void Manager::saveDialog() {
void Manager::saveAsDialog(bool setPath) { void Manager::saveAsDialog(bool setPath) {
std::string dir; std::string dir;
std::string filename; std::string filename;
if (this->path == "") {
if (this->path != "") {
dir = system::getDirectory(this->path);
filename = system::getFilename(this->path);
}

// Default to <Rack user dir>/patches
if (dir == "" || !system::isDirectory(dir)) {
dir = asset::user("patches"); dir = asset::user("patches");
system::createDirectories(dir); 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); osdialog_filters* filters = osdialog_filters_parse(PATCH_FILTERS);
@@ -384,13 +389,15 @@ void Manager::loadDialog() {
return; return;


std::string dir; std::string dir;
if (this->path == "") {
if (this->path != "") {
dir = system::getDirectory(this->path);
}

// Default to <Rack user dir>/patches
if (dir == "" || !system::isDirectory(dir)) {
dir = asset::user("patches"); dir = asset::user("patches");
system::createDirectory(dir); system::createDirectory(dir);
} }
else {
dir = system::getDirectory(this->path);
}


osdialog_filters* filters = osdialog_filters_parse(PATCH_FILTERS); osdialog_filters* filters = osdialog_filters_parse(PATCH_FILTERS);
DEFER({osdialog_filters_free(filters);}); DEFER({osdialog_filters_free(filters);});


Loading…
Cancel
Save