aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-12-21 12:05:26 -0800
committerChris Robinson <[email protected]>2016-12-21 12:05:26 -0800
commitdedc782222bf2f7f9a2210b686ebb1e922585bd1 (patch)
treeedaaf7b1df6943bb00428a2243956c0a6b77017e
parent1b104dd77baeb6d991ec2ff279c87e6e46527d44 (diff)
Avoid duplicate HRTF entries in the UI
Similar to how the library handles it, duplicate entries of the same file are ignored. This could happen if, for example, XDG_DATA_DIRS contains the same path multiple times.
-rw-r--r--utils/alsoft-config/mainwindow.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/utils/alsoft-config/mainwindow.cpp b/utils/alsoft-config/mainwindow.cpp
index 8d5dfe02..e1212f2f 100644
--- a/utils/alsoft-config/mainwindow.cpp
+++ b/utils/alsoft-config/mainwindow.cpp
@@ -472,6 +472,7 @@ void MainWindow::showAboutPage()
QStringList MainWindow::collectHrtfs()
{
QStringList ret;
+ QStringList processed;
for(int i = 0;i < ui->hrtfFileList->count();i++)
{
@@ -481,13 +482,17 @@ QStringList MainWindow::collectHrtfs()
{
if(!fname.endsWith(".mhr", Qt::CaseInsensitive))
continue;
+ QString fullname = dir.absoluteFilePath(fname);
+ if(processed.contains(fullname))
+ continue;
+ processed.push_back(fullname);
QString name = fname.left(fname.length()-4);
if(!ret.contains(name))
ret.push_back(name);
else
{
- size_t i = 1;
+ size_t i = 2;
do {
QString s = name+" #"+QString::number(i);
if(!ret.contains(s))
@@ -512,13 +517,17 @@ QStringList MainWindow::collectHrtfs()
{
if(!fname.endsWith(".mhr", Qt::CaseInsensitive))
continue;
+ QString fullname = dir.absoluteFilePath(fname);
+ if(processed.contains(fullname))
+ continue;
+ processed.push_back(fullname);
QString name = fname.left(fname.length()-4);
if(!ret.contains(name))
ret.push_back(name);
else
{
- size_t i = 1;
+ size_t i = 2;
do {
QString s = name+" #"+QString::number(i);
if(!ret.contains(s))