From 21ed20bce137214786510e5d91503263c90a59a9 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Fri, 30 Oct 2020 08:00:41 +0100 Subject: [PATCH] Ensure that default paths don't have duplicates --- vst/SfizzFileScan.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vst/SfizzFileScan.cpp b/vst/SfizzFileScan.cpp index ae2c4b60..c9251593 100644 --- a/vst/SfizzFileScan.cpp +++ b/vst/SfizzFileScan.cpp @@ -8,6 +8,7 @@ #include "SfizzForeignPaths.h" #include "NativeHelpers.h" #include +#include #include #include @@ -182,14 +183,18 @@ absl::Span sfzDefaultPaths() static const auto paths = []() -> std::vector { std::vector paths; paths.reserve(8); + auto addPath = [&paths](const fs::path& newPath) { + if (absl::c_find(paths, newPath) == paths.end()) + paths.push_back(newPath); + }; - paths.push_back(getUserDocumentsDirectory() / "SFZ instruments"); + addPath(getUserDocumentsDirectory() / "SFZ instruments"); for (const fs::path& foreign : { getAriaPathSetting("user_files_dir"), getAriaPathSetting("Converted_path") }) if (!foreign.empty() && foreign.is_absolute()) - paths.push_back(foreign); + addPath(foreign); paths.shrink_to_fit(); return paths;