From 9e469ad030bf852fb687227a4c1baf1d0378c834 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 6 Sep 2024 20:00:36 +0200 Subject: [PATCH] macVST: prevent endless recursive scans --- libs/ardour/ardour/plugin_manager.h | 2 +- libs/ardour/plugin_manager.cc | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/ardour/ardour/plugin_manager.h b/libs/ardour/ardour/plugin_manager.h index 4c93a7e7f6..8716024d6f 100644 --- a/libs/ardour/ardour/plugin_manager.h +++ b/libs/ardour/ardour/plugin_manager.h @@ -343,7 +343,7 @@ private: void lv2_refresh (); int windows_vst_discover_from_path (std::string path, bool cache_only = false); - int mac_vst_discover_from_path (std::string path, bool cache_only = false); + int mac_vst_discover_from_path (std::string path, std::set&, bool cache_only = false); int lxvst_discover_from_path (std::string path, bool cache_only = false); #if (defined WINDOWS_VST_SUPPORT || defined MACVST_SUPPORT || defined LXVST_SUPPORT) bool vst2_plugin (std::string const& module_path, ARDOUR::PluginType, VST2Info const&); diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index fa11030a01..cd4158f484 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -1801,13 +1801,14 @@ PluginManager::windows_vst_discover_from_path (string path, bool cache_only) void PluginManager::mac_vst_refresh (bool cache_only) { + std::set scanned_paths; if (_mac_vst_plugin_info) { _mac_vst_plugin_info->clear (); } else { _mac_vst_plugin_info = new ARDOUR::PluginInfoList(); } - mac_vst_discover_from_path ("~/Library/Audio/Plug-Ins/VST:/Library/Audio/Plug-Ins/VST", cache_only); + mac_vst_discover_from_path ("~/Library/Audio/Plug-Ins/VST:/Library/Audio/Plug-Ins/VST", scanned_paths, cache_only); if (!cache_only) { /* ensure that VST path is flushed to disk */ Config->save_state(); @@ -1824,7 +1825,7 @@ static bool mac_vst_filter (const string& str) } int -PluginManager::mac_vst_discover_from_path (string path, bool cache_only) +PluginManager::mac_vst_discover_from_path (string path, std::set& scanned_paths, bool cache_only) { vector plugin_objects; vector::iterator x; @@ -1834,6 +1835,11 @@ PluginManager::mac_vst_discover_from_path (string path, bool cache_only) return -1; } + if (scanned_paths.find (path) != scanned_paths::end) { + return 0; + } + scanned_paths.insert (path); + Searchpath paths (path); /* customized version of run_functor_for_paths() */ for (vector::const_iterator i = paths.begin(); i != paths.end(); ++i) { @@ -1860,7 +1866,7 @@ PluginManager::mac_vst_discover_from_path (string path, bool cache_only) } /* recurse */ - mac_vst_discover_from_path (fullpath, cache_only); + mac_vst_discover_from_path (fullpath, scanned_paths, cache_only); } } catch (Glib::FileError& err) { } }