From 34f8e79623c0b443820125a3ecfa1673006b290a Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 25 Jul 2017 23:20:10 -0400 Subject: [PATCH] Bug1590: Mac skips plugin cfg entries for .ny's of other versions... ... This conservative fix depends on where you put the executable bundle. Assuing the executable is in /Applications, and the other Audacity version (past or future) is there too (either bundled as for 2.1.3 and later, or in a folder as for 2.1.2 and previous): The .ny files that are part of the other version's shipment are ignored, and therefore the Effects menu avoids duplicates. But the .cfg file is not rewritten to eliminate them, in case you want to switch back to the other version. If that other version is 2.1.3 or earlier, sorry but you will see duplicates. --- src/PluginManager.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index 2b2050f7a..20c1c5120 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -1770,6 +1770,40 @@ void PluginManager::Load() void PluginManager::LoadGroup(wxFileConfig *pRegistry, PluginType type) { +#ifdef __WXMAC__ + // Bug 1590: On Mac, we should purge the registry of Nyquist plug-ins + // bundled with other versions of Audacity, assuming both versions + // were properly installed in /Applications (or whatever it is called in + // your locale) + + const auto fullExePath = PlatformCompatibility::GetExecutablePath(); + + // Strip rightmost path components up to *.app + wxFileName exeFn{ fullExePath }; + exeFn.SetEmptyExt(); + exeFn.SetName(wxString{}); + while(exeFn.GetDirCount() && !exeFn.GetDirs().Last().EndsWith(".app")) + exeFn.RemoveLastDir(); + + const auto goodPath = exeFn.GetPath(); + + if(exeFn.GetDirCount()) + exeFn.RemoveLastDir(); + const auto possiblyBadPath = exeFn.GetPath(); + + auto AcceptPath = [&](const wxString &path) { + if (!path.StartsWith(possiblyBadPath)) + // Assume it's not under /Applications + return true; + if (path.StartsWith(goodPath)) + // It's bundled with this executable + return true; + return false; + }; +#else + auto AcceptPath = [](const wxString&){ return true; }; +#endif + wxString strVal; bool boolVal; wxString groupName; @@ -1814,6 +1848,11 @@ void PluginManager::LoadGroup(wxFileConfig *pRegistry, PluginType type) // Get the path (optional) pRegistry->Read(KEY_PATH, &strVal, wxEmptyString); + if (!AcceptPath(strVal)) + // Ignore the obsolete path in the config file, during session, + // but don't remove it from the file. Maybe you really want to + // switch back to the other version of Audacity and lose nothing. + continue; plug.SetPath(strVal); // Get the name and bypass group if not found