From 7545ada7e3d71cec04e3165511aad132ec299129 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 22 Apr 2024 02:28:59 -0400 Subject: [PATCH] Use default patch dir in open/save dialogs if current patch dir doesn't exist. --- src/patch.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) 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);});