From d6e4e0fb354527461210e6593b80c9f3d2afc9a6 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 16 Oct 2021 20:03:34 +0200 Subject: [PATCH] Remove false-positive VST log message Ardour prevents repeat crashes by first marking a plugin as blacklisted, and after a successful scan the plugin is whitelisted. When not scanning for plugins, but reading the cache and successfully parsing the cashed content, a VST2 plugin is whitelisted, even though it may not have been blacklisted. In case the blacklist is empty, this lead to a logging: "Expected VST Blacklist file does not exist." PS. This also consolidates VST2 + VST3 code for white/blacklist --- libs/ardour/plugin_manager.cc | 45 ++++++++++++++++------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index d30e9ca814..f5cc878fd7 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -1420,15 +1420,33 @@ PluginManager::au_refresh (bool cache_only) #if (defined WINDOWS_VST_SUPPORT || defined MACVST_SUPPORT || defined LXVST_SUPPORT) +static bool vst2_is_blacklisted (string const& module_path) +{ + string fn = Glib::build_filename (ARDOUR::user_cache_directory (), VST2_BLACKLIST); + if (!Glib::file_test (fn, Glib::FILE_TEST_EXISTS)) { + return false; + } + + std::string bl; + try { + bl = Glib::file_get_contents (fn); + } catch (Glib::FileError const& err) { + return false; + } + return bl.find (module_path + "\n") != string::npos; +} + static void vst2_blacklist (string const& module_path) { + if (module_path.empty () || vst2_is_blacklisted (module_path)) { + return; + } string fn = Glib::build_filename (ARDOUR::user_cache_directory (), VST2_BLACKLIST); FILE* f = NULL; if (! (f = g_fopen (fn.c_str (), "a"))) { PBD::error << string_compose (_("Cannot write to VST2 blacklist file '%1'"), fn) << endmsg; return; } - assert (NULL == strchr (module_path.c_str(), '\n')); fprintf (f, "%s\n", module_path.c_str ()); ::fclose (f); } @@ -1437,7 +1455,6 @@ static void vst2_whitelist (string module_path) { string fn = Glib::build_filename (ARDOUR::user_cache_directory (), VST2_BLACKLIST); if (!Glib::file_test (fn, Glib::FILE_TEST_EXISTS)) { - PBD::warning << _("Expected VST Blacklist file does not exist.") << endmsg; return; } @@ -1460,22 +1477,6 @@ static void vst2_whitelist (string module_path) Glib::file_set_contents (fn, bl); } -static bool vst2_is_blacklisted (string const& module_path) -{ - string fn = Glib::build_filename (ARDOUR::user_cache_directory (), VST2_BLACKLIST); - if (!Glib::file_test (fn, Glib::FILE_TEST_EXISTS)) { - return false; - } - - std::string bl; - try { - bl = Glib::file_get_contents (fn); - } catch (Glib::FileError const& err) { - return false; - } - return bl.find (module_path + "\n") != string::npos; -} - static void vst2_scanner_log (std::string msg, std::stringstream* ss) { *ss << msg; @@ -1702,17 +1703,13 @@ PluginManager::vst2_discover (string path, ARDOUR::PluginType type, bool cache_o if (!tree.root()->get_property ("binary", binary) || binary != path) { psle->msg (PluginScanLogEntry::Incompatible, string_compose (_("Invalid VST2 cache file '%1'"), cache_file)); // XXX log as error msg psle->msg (PluginScanLogEntry::Blacklisted); - if (!vst2_is_blacklisted (path)) { - vst2_blacklist (path); - } + vst2_blacklist (path); return -1; } std::string arch; if (!tree.root()->get_property ("arch", arch) || arch != vst2_arch ()) { - if (!vst2_is_blacklisted (path)) { - vst2_blacklist (path); - } + vst2_blacklist (path); psle->msg (PluginScanLogEntry::Blacklisted); psle->msg (PluginScanLogEntry::Incompatible, string_compose (_("VST2 architecture mismatches '%1'"), arch)); return -1;