add <use_no_of_threads> tag to musredit_startup.xml if it is missing and the preferences are saved.
This commit is contained in:
1 parent
6e1a7fe0d3
commit
06e76aa801
2 files changed
+49
-1
No files matched your search
@@ -949,6 +949,7 @@ int PAdmin::savePrefs(QString pref_fln)
|
||||
file.close();
|
||||
|
||||
// replace all the prefs
|
||||
bool noOfThreadsFound = false;
|
||||
for (int i=0; i<data.size(); i++) {
|
||||
if (data[i].contains("<timeout>") && data[i].contains("</timeout>")) {
|
||||
data[i] = " <timeout>" + QString("%1").arg(fTimeout) + "</timeout>";
|
||||
@@ -996,6 +997,7 @@ int PAdmin::savePrefs(QString pref_fln)
|
||||
data[i] = " <yaml_out>n</yaml_out>";
|
||||
}
|
||||
if (data[i].contains("<use_no_of_threads>") && data[i].contains("</use_no_of_threads>")) {
|
||||
noOfThreadsFound = true;
|
||||
data[i] = " <use_no_of_threads>" + QString("%1").arg(fNoOfThreadsToBeUsed) + "</use_no_of_threads>";
|
||||
}
|
||||
if (data[i].contains("<musrview_show_fourier>") && data[i].contains("</musrview_show_fourier>")) {
|
||||
@@ -1042,6 +1044,28 @@ int PAdmin::savePrefs(QString pref_fln)
|
||||
}
|
||||
}
|
||||
|
||||
// <use_no_of_threads> missing (older startup file): add it, preferably after <yaml_out>, otherwise at the end of <general>
|
||||
if (!noOfThreadsFound) {
|
||||
QString line = " <use_no_of_threads>" + QString("%1").arg(fNoOfThreadsToBeUsed) + "</use_no_of_threads>";
|
||||
int idx = -1;
|
||||
for (int i=0; i<data.size(); i++) {
|
||||
if (data[i].contains("</yaml_out>")) {
|
||||
idx = i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (idx == -1) {
|
||||
for (int i=0; i<data.size(); i++) {
|
||||
if (data[i].contains("</general>")) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (idx != -1)
|
||||
data.insert(idx, line);
|
||||
}
|
||||
|
||||
// write prefs
|
||||
file.setFileName(pref_fln);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
|
||||
@@ -1095,6 +1095,7 @@ int PAdmin::savePrefs(QString pref_fln)
|
||||
file.close();
|
||||
|
||||
// replace all the prefs
|
||||
bool noOfThreadsFound = false;
|
||||
for (int i=0; i<data.size(); i++) {
|
||||
if (data[i].contains("<timeout>") && data[i].contains("</timeout>")) {
|
||||
data[i] = " <timeout>" + QString("%1").arg(fTimeout) + "</timeout>";
|
||||
@@ -1142,7 +1143,8 @@ int PAdmin::savePrefs(QString pref_fln)
|
||||
data[i] = " <yaml_out>n</yaml_out>";
|
||||
}
|
||||
if (data[i].contains("<use_no_of_threads>") && data[i].contains("</use_no_of_threads>")) {
|
||||
data[i] = " <use_no_of_threads>" + QString("%1").arg(fNoOfThreadsToBeUsed) + "</use_no_of_threads>";
|
||||
noOfThreadsFound = true;
|
||||
data[i] = " <use_no_of_threads>" + QString("%1").arg(fNoOfThreadsToBeUsed) + "</use_no_of_threads>";
|
||||
}
|
||||
if (data[i].contains("<musrview_show_fourier>") && data[i].contains("</musrview_show_fourier>")) {
|
||||
if (fMusrviewShowFourier)
|
||||
@@ -1188,6 +1190,28 @@ int PAdmin::savePrefs(QString pref_fln)
|
||||
}
|
||||
}
|
||||
|
||||
// <use_no_of_threads> missing (older startup file): add it, preferably after <yaml_out>, otherwise at the end of <general>
|
||||
if (!noOfThreadsFound) {
|
||||
QString line = " <use_no_of_threads>" + QString("%1").arg(fNoOfThreadsToBeUsed) + "</use_no_of_threads>";
|
||||
int idx = -1;
|
||||
for (int i=0; i<data.size(); i++) {
|
||||
if (data[i].contains("</yaml_out>")) {
|
||||
idx = i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (idx == -1) {
|
||||
for (int i=0; i<data.size(); i++) {
|
||||
if (data[i].contains("</general>")) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (idx != -1)
|
||||
data.insert(idx, line);
|
||||
}
|
||||
|
||||
// write prefs
|
||||
file.setFileName(pref_fln);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
|
||||
Reference in new issue
Block a user