From a63a18a3387b90c0920d9b1668d2a50bd6302b83 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 10 Feb 2022 18:20:18 +0100 Subject: [PATCH] Do not allow to add the same folder to the clip library path twice --- gtk2_ardour/trigger_clip_picker.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/trigger_clip_picker.cc b/gtk2_ardour/trigger_clip_picker.cc index b01d07cb97..95de6b0860 100644 --- a/gtk2_ardour/trigger_clip_picker.cc +++ b/gtk2_ardour/trigger_clip_picker.cc @@ -585,14 +585,18 @@ TriggerClipPicker::drag_data_received (Glib::RefPtr const& con } else { bool changed = false; std::string path; + std::string path_to_list; std::vector paths; std::vector a = PBD::parse_path (Config->get_sample_lib_path ()); if (ARDOUR_UI_UTILS::convert_drop_to_paths (paths, data)) { for (std::vector::const_iterator s = paths.begin (); s != paths.end (); ++s) { if (Glib::file_test (*s, Glib::FILE_TEST_IS_DIR | Glib::FILE_TEST_EXISTS)) { - a.push_back (*s); - changed = true; + if (std::find (a.begin(), a.end(), *s) == a.end()) { + a.push_back (*s); + changed = true; + } + path_to_list = *s; } } if (changed) { @@ -603,7 +607,9 @@ TriggerClipPicker::drag_data_received (Glib::RefPtr const& con path += *i; } Config->set_sample_lib_path (path); - list_dir (a.back ()); + } + if (!path_to_list.empty ()) { + list_dir (path_to_list); } } } @@ -644,6 +650,10 @@ TriggerClipPicker::open_dir () size_t j = 0; std::string path; std::vector a = PBD::parse_path (Config->get_sample_lib_path ()); + if (std::find (a.begin(), a.end(), _fcd.get_filename ()) != a.end()) { + list_dir (_fcd.get_filename ()); + break; + } a.push_back (_fcd.get_filename ()); for (std::vector::const_iterator i = a.begin (); i != a.end (); ++i, ++j) { if (j > 0)