From 15379301957533cf5204153df747af5a61d8168d Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 18 Dec 2019 00:27:40 -0500 Subject: [PATCH] DiscoverPluginsAtPath reports error as TranslatableString --- include/audacity/ModuleInterface.h | 2 +- src/ModuleManager.cpp | 4 ++-- src/ModuleManager.h | 2 +- src/PluginManager.cpp | 15 ++++++++------- src/commands/LoadCommands.cpp | 8 ++++---- src/commands/LoadCommands.h | 2 +- src/effects/LoadEffects.cpp | 8 ++++---- src/effects/LoadEffects.h | 2 +- src/effects/VST/VSTEffect.cpp | 6 +++--- src/effects/VST/VSTEffect.h | 2 +- src/effects/audiounits/AudioUnitEffect.cpp | 8 ++++---- src/effects/audiounits/AudioUnitEffect.h | 2 +- src/effects/ladspa/LadspaEffect.cpp | 12 ++++++------ src/effects/ladspa/LadspaEffect.h | 2 +- src/effects/lv2/LoadLV2.cpp | 6 +++--- src/effects/lv2/LoadLV2.h | 2 +- src/effects/nyquist/LoadNyquist.cpp | 6 +++--- src/effects/nyquist/LoadNyquist.h | 2 +- src/effects/nyquist/Nyquist.cpp | 13 ++++++------- src/effects/nyquist/Nyquist.h | 4 ++-- src/effects/vamp/LoadVamp.cpp | 6 +++--- src/effects/vamp/LoadVamp.h | 2 +- 22 files changed, 58 insertions(+), 58 deletions(-) diff --git a/include/audacity/ModuleInterface.h b/include/audacity/ModuleInterface.h index cd66790f4..c5e826ab1 100644 --- a/include/audacity/ModuleInterface.h +++ b/include/audacity/ModuleInterface.h @@ -120,7 +120,7 @@ public: std::function< const PluginID &(ModuleInterface *, ComponentInterface *) >; virtual unsigned DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback ) = 0; diff --git a/src/ModuleManager.cpp b/src/ModuleManager.cpp index 3e7ef9d8a..ca6dbab07 100755 --- a/src/ModuleManager.cpp +++ b/src/ModuleManager.cpp @@ -545,9 +545,9 @@ PluginPaths ModuleManager::FindPluginsForProvider(const PluginID & providerID, return mDynModules[providerID]->FindPluginPaths(PluginManager::Get()); } -bool ModuleManager::RegisterEffectPlugin(const PluginID & providerID, const PluginPath & path, wxString &errMsg) +bool ModuleManager::RegisterEffectPlugin(const PluginID & providerID, const PluginPath & path, TranslatableString &errMsg) { - errMsg.clear(); + errMsg = {}; if (mDynModules.find(providerID) == mDynModules.end()) { return false; diff --git a/src/ModuleManager.h b/src/ModuleManager.h index 4276e08cb..f5ef054cd 100644 --- a/src/ModuleManager.h +++ b/src/ModuleManager.h @@ -100,7 +100,7 @@ public: PluginPaths FindPluginsForProvider(const PluginID & provider, const PluginPath & path); bool RegisterEffectPlugin(const PluginID & provider, const PluginPath & path, - wxString &errMsg); + TranslatableString &errMsg); ModuleInterface *CreateProviderInstance(const PluginID & provider, const PluginPath & path); ComponentInterface *CreateInstance(const PluginID & provider, const PluginPath & path); diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index b51684e4f..57ef3ddeb 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -1008,12 +1008,12 @@ void PluginRegistrationDialog::OnOK(wxCommandEvent & WXUNUSED(evt)) break; } - wxString errMsgs; + TranslatableString errMsgs; // Try to register the plugin via each provider until one succeeds for (size_t j = 0, cntj = item.plugs.size(); j < cntj; j++) { - wxString errMsg; + TranslatableString errMsg; if (mm.RegisterEffectPlugin(item.plugs[j]->GetProviderID(), path, errMsg)) { @@ -1023,14 +1023,15 @@ void PluginRegistrationDialog::OnOK(wxCommandEvent & WXUNUSED(evt)) } // Bug 1893. We've found a provider that works. // Error messages from any that failed are no longer useful. - errMsgs.clear(); + errMsgs = {}; break; } else { - if (errMsgs.empty()) - errMsgs += '\n'; - errMsgs += errMsg; + if (!errMsgs.empty()) + errMsgs.Join( errMsg, '\n' ); + else + errMsgs = errMsg; } } if (!errMsgs.empty()) @@ -1818,7 +1819,7 @@ bool PluginManager::DropFile(const wxString &fileName) const auto &extensions = module->GetFileExtensions(); if ( !ff.empty() && extensions.Index(src.GetExt(), false) != wxNOT_FOUND ) { - wxString errMsg; + TranslatableString errMsg; // Do dry-run test of the file format unsigned nPlugIns = module->DiscoverPluginsAtPath(fileName, errMsg, {}); diff --git a/src/commands/LoadCommands.cpp b/src/commands/LoadCommands.cpp index 53bd73faa..4edcfbdda 100644 --- a/src/commands/LoadCommands.cpp +++ b/src/commands/LoadCommands.cpp @@ -238,7 +238,7 @@ const FileExtensions &BuiltinCommandsModule::GetFileExtensions() bool BuiltinCommandsModule::AutoRegisterPlugins(PluginManagerInterface & pm) { - wxString ignoredErrMsg; + TranslatableString ignoredErrMsg; const auto &names = kCOMMANDNames(); for (const auto &name : names) { @@ -264,10 +264,10 @@ PluginPaths BuiltinCommandsModule::FindPluginPaths(PluginManagerInterface & WXUN } unsigned BuiltinCommandsModule::DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) { - errMsg.clear(); + errMsg = {}; auto Command = Instantiate(path); if (Command) { @@ -277,7 +277,7 @@ unsigned BuiltinCommandsModule::DiscoverPluginsAtPath( return 1; } - errMsg = _("Unknown built-in command name"); + errMsg = XO("Unknown built-in command name"); return 0; } diff --git a/src/commands/LoadCommands.h b/src/commands/LoadCommands.h index 9bda7f6c1..b7926d535 100644 --- a/src/commands/LoadCommands.h +++ b/src/commands/LoadCommands.h @@ -47,7 +47,7 @@ public: bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; unsigned DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) override; diff --git a/src/effects/LoadEffects.cpp b/src/effects/LoadEffects.cpp index e07a33a07..fc2b63acc 100644 --- a/src/effects/LoadEffects.cpp +++ b/src/effects/LoadEffects.cpp @@ -307,7 +307,7 @@ const FileExtensions &BuiltinEffectsModule::GetFileExtensions() bool BuiltinEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm) { - wxString ignoredErrMsg; + TranslatableString ignoredErrMsg; const auto &names = kEffectNames(); for (const auto &name : names) { @@ -331,10 +331,10 @@ PluginPaths BuiltinEffectsModule::FindPluginPaths(PluginManagerInterface & WXUNU } unsigned BuiltinEffectsModule::DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) { - errMsg.clear(); + errMsg = {}; auto effect = Instantiate(path); if (effect) { @@ -343,7 +343,7 @@ unsigned BuiltinEffectsModule::DiscoverPluginsAtPath( return 1; } - errMsg = _("Unknown built-in effect name"); + errMsg = XO("Unknown built-in effect name"); return 0; } diff --git a/src/effects/LoadEffects.h b/src/effects/LoadEffects.h index 8073f452c..c94e343c1 100644 --- a/src/effects/LoadEffects.h +++ b/src/effects/LoadEffects.h @@ -46,7 +46,7 @@ public: bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; unsigned DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) override; diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 6d2390f76..88347299b 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -505,12 +505,12 @@ PluginPaths VSTEffectsModule::FindPluginPaths(PluginManagerInterface & pm) } unsigned VSTEffectsModule::DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) { bool error = false; unsigned nFound = 0; - errMsg.clear(); + errMsg = {}; // TODO: Fix this for external usage const auto &cmdpath = PlatformCompatibility::GetExecutablePath(); @@ -675,7 +675,7 @@ unsigned VSTEffectsModule::DiscoverPluginsAtPath( } if (error) - errMsg = _("Could not load the library"); + errMsg = XO("Could not load the library"); return nFound; } diff --git a/src/effects/VST/VSTEffect.h b/src/effects/VST/VSTEffect.h index 27f09dea5..56314d7cc 100644 --- a/src/effects/VST/VSTEffect.h +++ b/src/effects/VST/VSTEffect.h @@ -425,7 +425,7 @@ public: bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; unsigned DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) override; diff --git a/src/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp index 1c4517c26..73ca66333 100644 --- a/src/effects/audiounits/AudioUnitEffect.cpp +++ b/src/effects/audiounits/AudioUnitEffect.cpp @@ -182,15 +182,15 @@ PluginPaths AudioUnitEffectsModule::FindPluginPaths(PluginManagerInterface & pm) } unsigned AudioUnitEffectsModule::DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) { - errMsg.clear(); + errMsg = {}; wxString name; AudioComponent component = FindAudioUnit(path, name); if (component == NULL) { - errMsg = _("Could not find component"); + errMsg = XO("Could not find component"); return 0; } @@ -199,7 +199,7 @@ unsigned AudioUnitEffectsModule::DiscoverPluginsAtPath( { // TODO: Is it worth it to discriminate all the ways SetHost might // return false? - errMsg = _("Could not initialize component"); + errMsg = XO("Could not initialize component"); return 0; } diff --git a/src/effects/audiounits/AudioUnitEffect.h b/src/effects/audiounits/AudioUnitEffect.h index e25cfb999..eb0d6cdc4 100644 --- a/src/effects/audiounits/AudioUnitEffect.h +++ b/src/effects/audiounits/AudioUnitEffect.h @@ -249,7 +249,7 @@ public: bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; unsigned DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) override; diff --git a/src/effects/ladspa/LadspaEffect.cpp b/src/effects/ladspa/LadspaEffect.cpp index a14613ffa..34a1cf4e3 100644 --- a/src/effects/ladspa/LadspaEffect.cpp +++ b/src/effects/ladspa/LadspaEffect.cpp @@ -206,7 +206,7 @@ bool LadspaEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm) // Audacity. A little simplistic, but it should suffice for now. auto pathList = GetSearchPaths(); FilePaths files; - wxString ignoredErrMsg; + TranslatableString ignoredErrMsg; for (int i = 0; i < (int)WXSIZEOF(kShippedEffects); i++) { @@ -253,15 +253,15 @@ PluginPaths LadspaEffectsModule::FindPluginPaths(PluginManagerInterface & pm) } unsigned LadspaEffectsModule::DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) { - errMsg.clear(); + errMsg = {}; // Since we now have builtin VST support, ignore the VST bridge as it // causes duplicate menu entries to appear. wxFileName ff(path); if (ff.GetName().CmpNoCase(wxT("vst-bridge")) == 0) { - errMsg = _("Audacity no longer uses vst-bridge"); + errMsg = XO("Audacity no longer uses vst-bridge"); return 0; } @@ -300,12 +300,12 @@ unsigned LadspaEffectsModule::DiscoverPluginsAtPath( callback( this, &effect ); } else - errMsg = _("Could not load the library"); + errMsg = XO("Could not load the library"); } } } else - errMsg = _("Could not load the library"); + errMsg = XO("Could not load the library"); #if defined(__WXMSW__) if (lib.IsLoaded()) { diff --git a/src/effects/ladspa/LadspaEffect.h b/src/effects/ladspa/LadspaEffect.h index a931dc41e..28d4b0ae0 100644 --- a/src/effects/ladspa/LadspaEffect.h +++ b/src/effects/ladspa/LadspaEffect.h @@ -230,7 +230,7 @@ public: bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; unsigned DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) override; diff --git a/src/effects/lv2/LoadLV2.cpp b/src/effects/lv2/LoadLV2.cpp index 35a804a40..55f5c4a5a 100755 --- a/src/effects/lv2/LoadLV2.cpp +++ b/src/effects/lv2/LoadLV2.cpp @@ -277,10 +277,10 @@ PluginPaths LV2EffectsModule::FindPluginPaths(PluginManagerInterface & WXUNUSED( } unsigned LV2EffectsModule::DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) { - errMsg.clear(); + errMsg = {}; const LilvPlugin *plug = GetPlugin(path); if (plug) { @@ -293,7 +293,7 @@ unsigned LV2EffectsModule::DiscoverPluginsAtPath( } } - errMsg = _("Could not load the library"); + errMsg = XO("Could not load the library"); return 0; } diff --git a/src/effects/lv2/LoadLV2.h b/src/effects/lv2/LoadLV2.h index 69ce8f0a4..722a96b2f 100755 --- a/src/effects/lv2/LoadLV2.h +++ b/src/effects/lv2/LoadLV2.h @@ -186,7 +186,7 @@ public: bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; unsigned DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) override; diff --git a/src/effects/nyquist/LoadNyquist.cpp b/src/effects/nyquist/LoadNyquist.cpp index 52b523c23..cdac7e6b8 100644 --- a/src/effects/nyquist/LoadNyquist.cpp +++ b/src/effects/nyquist/LoadNyquist.cpp @@ -181,7 +181,7 @@ bool NyquistEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm) // Audacity. A little simplistic, but it should suffice for now. auto pathList = NyquistEffect::GetNyquistSearchPath(); FilePaths files; - wxString ignoredErrMsg; + TranslatableString ignoredErrMsg; if (!pm.IsPluginRegistered(NYQUIST_PROMPT_ID)) { @@ -226,10 +226,10 @@ PluginPaths NyquistEffectsModule::FindPluginPaths(PluginManagerInterface & pm) } unsigned NyquistEffectsModule::DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) { - errMsg.clear(); + errMsg = {}; NyquistEffect effect(path); if (effect.IsOk()) { diff --git a/src/effects/nyquist/LoadNyquist.h b/src/effects/nyquist/LoadNyquist.h index 6d12a2801..e91cba0fb 100644 --- a/src/effects/nyquist/LoadNyquist.h +++ b/src/effects/nyquist/LoadNyquist.h @@ -45,7 +45,7 @@ public: bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; unsigned DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) override; diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index 266db8d91..10a7f3aa0 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -193,7 +193,7 @@ NyquistEffect::NyquistEffect(const wxString &fName) ParseFile(); if (!mOK && mInitError.empty()) - mInitError = _("Ill-formed Nyquist plug-in header"); + mInitError = XO("Ill-formed Nyquist plug-in header"); } NyquistEffect::~NyquistEffect() @@ -1887,10 +1887,9 @@ bool NyquistEffect::Parse( if (v < 1 || v > 4) { // This is an unsupported plug-in version mOK = false; - mInitError.Format( - _("This version of Audacity does not support Nyquist plug-in version %ld"), - v - ); + mInitError = XO( +"This version of Audacity does not support Nyquist plug-in version %ld") + .Format( v ); return true; } mVersion = (int) v; @@ -2143,7 +2142,7 @@ bool NyquistEffect::ParseProgram(wxInputStream & stream) { if (!stream.IsOk()) { - mInitError = _("Could not open file"); + mInitError = XO("Could not open file"); return false; } @@ -2224,7 +2223,7 @@ or for LISP, begin with an open parenthesis such as:\n\t(mult *track* 0.1)\n .") Effect::DefaultMessageBoxStyle, XO("Error in Nyquist code") ); /* i18n-hint: refers to programming "languages" */ - mInitError = _("Could not determine language"); + mInitError = XO("Could not determine language"); return false; // Else just throw it at Nyquist to see what happens } diff --git a/src/effects/nyquist/Nyquist.h b/src/effects/nyquist/Nyquist.h index 56fd2d09d..4f05c3481 100644 --- a/src/effects/nyquist/Nyquist.h +++ b/src/effects/nyquist/Nyquist.h @@ -128,7 +128,7 @@ private: bool TransferDataFromEffectWindow(); bool IsOk(); - const wxString &InitializationError() const { return mInitError; } + const TranslatableString &InitializationError() const { return mInitError; } static FilePaths GetNyquistSearchPath(); @@ -210,7 +210,7 @@ private: */ bool mIsPrompt; bool mOK; - wxString mInitError; + TranslatableString mInitError; wxString mInputCmd; // history: exactly what the user typed wxString mCmd; // the command to be processed TranslatableString mName; ///< Name of the Effect (untranslated) diff --git a/src/effects/vamp/LoadVamp.cpp b/src/effects/vamp/LoadVamp.cpp index a0af53a2b..64c414b0d 100644 --- a/src/effects/vamp/LoadVamp.cpp +++ b/src/effects/vamp/LoadVamp.cpp @@ -209,10 +209,10 @@ PluginPaths VampEffectsModule::FindPluginPaths(PluginManagerInterface & WXUNUSED } unsigned VampEffectsModule::DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) { - errMsg.clear(); + errMsg = {}; int output; bool hasParameters; @@ -226,7 +226,7 @@ unsigned VampEffectsModule::DiscoverPluginsAtPath( return 1; } - errMsg = _("Could not load the library"); + errMsg = XO("Could not load the library"); return 0; } diff --git a/src/effects/vamp/LoadVamp.h b/src/effects/vamp/LoadVamp.h index d24697e13..c88c7a54f 100644 --- a/src/effects/vamp/LoadVamp.h +++ b/src/effects/vamp/LoadVamp.h @@ -52,7 +52,7 @@ public: bool AutoRegisterPlugins(PluginManagerInterface & pm) override; PluginPaths FindPluginPaths(PluginManagerInterface & pm) override; unsigned DiscoverPluginsAtPath( - const PluginPath & path, wxString &errMsg, + const PluginPath & path, TranslatableString &errMsg, const RegistrationCallback &callback) override;