aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-02-28 09:34:02 -0800
committerChris Robinson <[email protected]>2016-02-28 18:30:12 -0800
commit81384949e2f3672ecd25797a31fbaa2d842492cd (patch)
tree245630fac540dcb1b9b431ef7f5f7c49dddd3439
parent9e3a1942a39efedf685c74f49763f917ca404269 (diff)
Properly check for preexisting HRTF names
-rw-r--r--utils/alsoft-config/mainwindow.cpp66
1 files changed, 34 insertions, 32 deletions
diff --git a/utils/alsoft-config/mainwindow.cpp b/utils/alsoft-config/mainwindow.cpp
index 44302e53..81b3a8e8 100644
--- a/utils/alsoft-config/mainwindow.cpp
+++ b/utils/alsoft-config/mainwindow.cpp
@@ -379,23 +379,24 @@ QStringList MainWindow::collectHrtfs()
QStringList fnames = dir.entryList(QDir::Files | QDir::Readable, QDir::Name);
foreach(const QString &fname, fnames)
{
- if(fname.endsWith(".mhr", Qt::CaseInsensitive))
+ if(!fname.endsWith(".mhr", Qt::CaseInsensitive))
+ continue;
+
+ QString name = fname.left(fname.length()-4);
+ if(!ret.contains(name))
+ ret.push_back(name);
+ else
{
- if(!ret.contains(fname))
- ret.push_back(fname.left(fname.length()-4));
- else
- {
- size_t i = 1;
- do {
- QString s = fname.left(fname.length()-4)+" #"+QString::number(i);
- if(!ret.contains(s))
- {
- ret.push_back(s);
- break;
- }
- ++i;
- } while(1);
- }
+ size_t i = 1;
+ do {
+ QString s = name+" #"+QString::number(i);
+ if(!ret.contains(s))
+ {
+ ret.push_back(s);
+ break;
+ }
+ ++i;
+ } while(1);
}
}
}
@@ -409,23 +410,24 @@ QStringList MainWindow::collectHrtfs()
QStringList fnames = dir.entryList(QDir::Files | QDir::Readable, QDir::Name);
foreach(const QString &fname, fnames)
{
- if(fname.endsWith(".mhr", Qt::CaseInsensitive))
+ if(!fname.endsWith(".mhr", Qt::CaseInsensitive))
+ continue;
+
+ QString name = fname.left(fname.length()-4);
+ if(!ret.contains(name))
+ ret.push_back(name);
+ else
{
- if(!ret.contains(fname))
- ret.push_back(fname.left(fname.length()-4));
- else
- {
- size_t i = 1;
- do {
- QString s = fname.left(fname.length()-4)+" #"+QString::number(i);
- if(!ret.contains(s))
- {
- ret.push_back(s);
- break;
- }
- ++i;
- } while(1);
- }
+ size_t i = 1;
+ do {
+ QString s = name+" #"+QString::number(i);
+ if(!ret.contains(s))
+ {
+ ret.push_back(s);
+ break;
+ }
+ ++i;
+ } while(1);
}
}
}