From dedc782222bf2f7f9a2210b686ebb1e922585bd1 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 21 Dec 2016 12:05:26 -0800 Subject: 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. --- utils/alsoft-config/mainwindow.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'utils/alsoft-config') 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)) -- cgit v1.2.3