From 1831b8bf3e2fbabd40b7314dad55fed1e0bf55f7 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Mon, 17 Dec 2018 17:30:58 +0100 Subject: [PATCH] Add Default Search Paths via musredit preferences if previously no search paths were present So far it was not possible to add Default Search Paths to musrfit via musredit if somebody delete all the predefined search paths. This bug is now fixed. --- .../musredit/PChangeDefaultPathsDialog.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/musredit_qt5/musredit/PChangeDefaultPathsDialog.cpp b/src/musredit_qt5/musredit/PChangeDefaultPathsDialog.cpp index cefe7ad9..a69aa86f 100644 --- a/src/musredit_qt5/musredit/PChangeDefaultPathsDialog.cpp +++ b/src/musredit_qt5/musredit/PChangeDefaultPathsDialog.cpp @@ -302,6 +302,17 @@ void PChangeDefaultPathsDialog::saveDefaultPathList() } fileIn.close(); + // check if there is any data_path is present in the musrfit_startup.xml + bool dataPathPresent = false; + QString str; + for (int i=0; i")) { + dataPathPresent = true; + break; + } + } + // write the new musrfit_startup.xml QFile fileOut(fDefaultPath->getPrefPathName()); if (!fileOut.open(QIODevice::WriteOnly | QIODevice::Text)) { @@ -309,11 +320,15 @@ void PChangeDefaultPathsDialog::saveDefaultPathList() return; } QTextStream out(&fileOut); - QString str; bool first = true; for (int i=0; i")) { + // if not data_path was present, add the new data_paths just before the end of the musrfit_start.xml close tag + if ((dataPathPresent == false) && (str.trimmed().startsWith(""))) { + for (int j=0; jcount(); j++) + out << " " << fSearchPath_listWidget->item(j)->text() << "" << endl; + } out << fileContent[i] << endl; } else { if (first) {