moduleMain functions were never called but with nullptr; so simplify

This commit is contained in:
Paul Licameli 2021-05-13 16:20:44 -04:00
parent 6242be0a8e
commit bd6fb75886
19 changed files with 36 additions and 97 deletions

View File

@ -140,7 +140,7 @@ public:
// be declared static so as not to interfere with other modules during link. // be declared static so as not to interfere with other modules during link.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#define DECLARE_MODULE_ENTRY(name) \ #define DECLARE_MODULE_ENTRY(name) \
static ModuleInterface * name(const wxString *path) static ModuleInterface * name()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// This will create a class and instance that will register the module entry // This will create a class and instance that will register the module entry

View File

@ -458,7 +458,7 @@ void ModuleManager::InitializeBuiltins()
for (auto moduleMain : builtinModuleList()) for (auto moduleMain : builtinModuleList())
{ {
ModuleInterfaceHandle module { ModuleInterfaceHandle module {
moduleMain(nullptr), ModuleInterfaceDeleter{} moduleMain(), ModuleInterfaceDeleter{}
}; };
if (module && module->Initialize()) if (module && module->Initialize())

View File

@ -130,9 +130,9 @@ private:
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// The module entry point prototype // The module entry point prototype (a factory of ModuleInterface objects)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
using ModuleMain = ModuleInterface *(*)(const wxString *path); using ModuleMain = ModuleInterface *(*)();
AUDACITY_DLL_API AUDACITY_DLL_API
void RegisterProvider(ModuleMain rtn); void RegisterProvider(ModuleMain rtn);

View File

@ -56,7 +56,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
{ {
// Create and register the importer // Create and register the importer
// Trust the module manager not to leak this // Trust the module manager not to leak this
return safenew BuiltinCommandsModule(path); return safenew BuiltinCommandsModule();
} }
// ============================================================================ // ============================================================================
@ -70,17 +70,12 @@ DECLARE_BUILTIN_MODULE(BuiltinsCommandBuiltin);
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
BuiltinCommandsModule::BuiltinCommandsModule(const wxString *path) BuiltinCommandsModule::BuiltinCommandsModule()
{ {
if (path)
{
mPath = *path;
}
} }
BuiltinCommandsModule::~BuiltinCommandsModule() BuiltinCommandsModule::~BuiltinCommandsModule()
{ {
mPath.clear();
} }
// ============================================================================ // ============================================================================
@ -89,7 +84,7 @@ BuiltinCommandsModule::~BuiltinCommandsModule()
PluginPath BuiltinCommandsModule::GetPath() PluginPath BuiltinCommandsModule::GetPath()
{ {
return mPath; return {};
} }
ComponentInterfaceSymbol BuiltinCommandsModule::GetSymbol() ComponentInterfaceSymbol BuiltinCommandsModule::GetSymbol()

View File

@ -30,7 +30,7 @@ class AudacityCommand;
class AUDACITY_DLL_API BuiltinCommandsModule final : public ModuleInterface class AUDACITY_DLL_API BuiltinCommandsModule final : public ModuleInterface
{ {
public: public:
BuiltinCommandsModule(const wxString *path); BuiltinCommandsModule();
virtual ~BuiltinCommandsModule(); virtual ~BuiltinCommandsModule();
using Factory = std::function< std::unique_ptr<AudacityCommand> () >; using Factory = std::function< std::unique_ptr<AudacityCommand> () >;
@ -83,8 +83,6 @@ private:
static void DoRegistration( static void DoRegistration(
const ComponentInterfaceSymbol &name, const Factory &factory ); const ComponentInterfaceSymbol &name, const Factory &factory );
wxString mPath;
using CommandHash = std::unordered_map< wxString, const Entry* > ; using CommandHash = std::unordered_map< wxString, const Entry* > ;
CommandHash mCommands; CommandHash mCommands;
}; };

View File

@ -54,7 +54,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
{ {
// Create and register the importer // Create and register the importer
// Trust the module manager not to leak this // Trust the module manager not to leak this
return safenew BuiltinEffectsModule(path); return safenew BuiltinEffectsModule();
} }
// ============================================================================ // ============================================================================
@ -68,17 +68,12 @@ DECLARE_BUILTIN_MODULE(BuiltinsEffectBuiltin);
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
BuiltinEffectsModule::BuiltinEffectsModule(const wxString *path) BuiltinEffectsModule::BuiltinEffectsModule()
{ {
if (path)
{
mPath = *path;
}
} }
BuiltinEffectsModule::~BuiltinEffectsModule() BuiltinEffectsModule::~BuiltinEffectsModule()
{ {
mPath.clear();
} }
// ============================================================================ // ============================================================================
@ -87,7 +82,7 @@ BuiltinEffectsModule::~BuiltinEffectsModule()
PluginPath BuiltinEffectsModule::GetPath() PluginPath BuiltinEffectsModule::GetPath()
{ {
return mPath; return {};
} }
ComponentInterfaceSymbol BuiltinEffectsModule::GetSymbol() ComponentInterfaceSymbol BuiltinEffectsModule::GetSymbol()

View File

@ -29,7 +29,7 @@ class Effect;
class AUDACITY_DLL_API BuiltinEffectsModule final : public ModuleInterface class AUDACITY_DLL_API BuiltinEffectsModule final : public ModuleInterface
{ {
public: public:
BuiltinEffectsModule(const wxString *path); BuiltinEffectsModule();
virtual ~BuiltinEffectsModule(); virtual ~BuiltinEffectsModule();
using Factory = std::function< std::unique_ptr<Effect> () >; using Factory = std::function< std::unique_ptr<Effect> () >;
@ -82,8 +82,6 @@ private:
const ComponentInterfaceSymbol &name, const Factory &factory, const ComponentInterfaceSymbol &name, const Factory &factory,
bool excluded ); bool excluded );
PluginPath mPath;
struct Entry; struct Entry;
using EffectHash = std::unordered_map< wxString, const Entry* > ; using EffectHash = std::unordered_map< wxString, const Entry* > ;
EffectHash mEffects; EffectHash mEffects;

View File

@ -143,7 +143,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
{ {
// Create our effects module and register // Create our effects module and register
// Trust the module manager not to leak this // Trust the module manager not to leak this
return safenew VSTEffectsModule(path); return safenew VSTEffectsModule();
} }
// ============================================================================ // ============================================================================
@ -306,17 +306,12 @@ public:
// VSTEffectsModule // VSTEffectsModule
// //
// ============================================================================ // ============================================================================
VSTEffectsModule::VSTEffectsModule(const wxString *path) VSTEffectsModule::VSTEffectsModule()
{ {
if (path)
{
mPath = *path;
}
} }
VSTEffectsModule::~VSTEffectsModule() VSTEffectsModule::~VSTEffectsModule()
{ {
mPath = wxEmptyString;
} }
// ============================================================================ // ============================================================================
@ -325,7 +320,7 @@ VSTEffectsModule::~VSTEffectsModule()
PluginPath VSTEffectsModule::GetPath() PluginPath VSTEffectsModule::GetPath()
{ {
return mPath; return {};
} }
ComponentInterfaceSymbol VSTEffectsModule::GetSymbol() ComponentInterfaceSymbol VSTEffectsModule::GetSymbol()

View File

@ -403,7 +403,7 @@ private:
class VSTEffectsModule final : public ModuleInterface class VSTEffectsModule final : public ModuleInterface
{ {
public: public:
VSTEffectsModule(const wxString *path); VSTEffectsModule();
virtual ~VSTEffectsModule(); virtual ~VSTEffectsModule();
// ComponentInterface implementation // ComponentInterface implementation
@ -438,9 +438,6 @@ public:
// VSTEffectModule implementation // VSTEffectModule implementation
static void Check(const wxChar *path); static void Check(const wxChar *path);
private:
PluginPath mPath;
}; };
#endif // USE_VST #endif // USE_VST

View File

@ -233,7 +233,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
{ {
// Create and register the importer // Create and register the importer
// Trust the module manager not to leak this // Trust the module manager not to leak this
return safenew AudioUnitEffectsModule(path); return safenew AudioUnitEffectsModule();
} }
// ============================================================================ // ============================================================================
@ -247,17 +247,12 @@ DECLARE_BUILTIN_MODULE(AudioUnitEffectsBuiltin);
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
AudioUnitEffectsModule::AudioUnitEffectsModule(const wxString *path) AudioUnitEffectsModule::AudioUnitEffectsModule()
{ {
if (path)
{
mPath = *path;
}
} }
AudioUnitEffectsModule::~AudioUnitEffectsModule() AudioUnitEffectsModule::~AudioUnitEffectsModule()
{ {
mPath.clear();
} }
// ============================================================================ // ============================================================================
@ -266,7 +261,7 @@ AudioUnitEffectsModule::~AudioUnitEffectsModule()
PluginPath AudioUnitEffectsModule::GetPath() PluginPath AudioUnitEffectsModule::GetPath()
{ {
return mPath; return {};
} }
ComponentInterfaceSymbol AudioUnitEffectsModule::GetSymbol() ComponentInterfaceSymbol AudioUnitEffectsModule::GetSymbol()

View File

@ -232,7 +232,7 @@ private:
class AudioUnitEffectsModule final : public ModuleInterface class AudioUnitEffectsModule final : public ModuleInterface
{ {
public: public:
AudioUnitEffectsModule(const wxString *path); AudioUnitEffectsModule();
virtual ~AudioUnitEffectsModule(); virtual ~AudioUnitEffectsModule();
// ComponentInterface implementation // ComponentInterface implementation
@ -271,9 +271,6 @@ public:
wxString FromOSType(OSType type); wxString FromOSType(OSType type);
OSType ToOSType(const wxString & type); OSType ToOSType(const wxString & type);
private:
wxString mPath;
}; };
#endif #endif

View File

@ -85,7 +85,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
{ {
// Create and register the importer // Create and register the importer
// Trust the module manager not to leak this // Trust the module manager not to leak this
return safenew LadspaEffectsModule(path); return safenew LadspaEffectsModule();
} }
// ============================================================================ // ============================================================================
@ -99,12 +99,8 @@ DECLARE_BUILTIN_MODULE(LadspaBuiltin);
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
LadspaEffectsModule::LadspaEffectsModule(const wxString *path) LadspaEffectsModule::LadspaEffectsModule()
{ {
if (path)
{
mPath = *path;
}
} }
LadspaEffectsModule::~LadspaEffectsModule() LadspaEffectsModule::~LadspaEffectsModule()
@ -117,7 +113,7 @@ LadspaEffectsModule::~LadspaEffectsModule()
PluginPath LadspaEffectsModule::GetPath() PluginPath LadspaEffectsModule::GetPath()
{ {
return mPath; return {};
} }
ComponentInterfaceSymbol LadspaEffectsModule::GetSymbol() ComponentInterfaceSymbol LadspaEffectsModule::GetSymbol()

View File

@ -208,7 +208,7 @@ private:
class LadspaEffectsModule final : public ModuleInterface class LadspaEffectsModule final : public ModuleInterface
{ {
public: public:
LadspaEffectsModule(const wxString *path); LadspaEffectsModule();
virtual ~LadspaEffectsModule(); virtual ~LadspaEffectsModule();
// ComponentInterface implementation // ComponentInterface implementation
@ -243,8 +243,5 @@ public:
// LadspaEffectModule implementation // LadspaEffectModule implementation
FilePaths GetSearchPaths(); FilePaths GetSearchPaths();
private:
wxString mPath;
}; };

View File

@ -60,7 +60,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
{ {
// Create and register the importer // Create and register the importer
// Trust the module manager not to leak this // Trust the module manager not to leak this
return safenew LV2EffectsModule(path); return safenew LV2EffectsModule();
} }
// ============================================================================ // ============================================================================
@ -77,12 +77,8 @@ using UriHash = std::unordered_map<wxString, LilvNode*>;
LilvWorld *gWorld = NULL; LilvWorld *gWorld = NULL;
LV2EffectsModule::LV2EffectsModule(const wxString *path) LV2EffectsModule::LV2EffectsModule()
{ {
if (path)
{
mPath = *path;
}
} }
LV2EffectsModule::~LV2EffectsModule() LV2EffectsModule::~LV2EffectsModule()
@ -95,7 +91,7 @@ LV2EffectsModule::~LV2EffectsModule()
PluginPath LV2EffectsModule::GetPath() PluginPath LV2EffectsModule::GetPath()
{ {
return mPath; return {};
} }
ComponentInterfaceSymbol LV2EffectsModule::GetSymbol() ComponentInterfaceSymbol LV2EffectsModule::GetSymbol()

View File

@ -163,7 +163,7 @@
class LV2EffectsModule final : public ModuleInterface class LV2EffectsModule final : public ModuleInterface
{ {
public: public:
LV2EffectsModule(const wxString *path); LV2EffectsModule();
virtual ~LV2EffectsModule(); virtual ~LV2EffectsModule();
// ComponentInterface implementation // ComponentInterface implementation
@ -199,9 +199,6 @@ public:
private: private:
const LilvPlugin *GetPlugin(const PluginPath & path); const LilvPlugin *GetPlugin(const PluginPath & path);
private:
PluginPath mPath;
}; };
extern LilvWorld *gWorld; extern LilvWorld *gWorld;

View File

@ -67,7 +67,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
{ {
// Create and register the importer // Create and register the importer
// Trust the module manager not to leak this // Trust the module manager not to leak this
return safenew NyquistEffectsModule(path); return safenew NyquistEffectsModule();
} }
// ============================================================================ // ============================================================================
@ -81,17 +81,12 @@ DECLARE_BUILTIN_MODULE(NyquistsEffectBuiltin);
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
NyquistEffectsModule::NyquistEffectsModule(const wxString *path) NyquistEffectsModule::NyquistEffectsModule()
{ {
if (path)
{
mPath = *path;
}
} }
NyquistEffectsModule::~NyquistEffectsModule() NyquistEffectsModule::~NyquistEffectsModule()
{ {
mPath.clear();
} }
// ============================================================================ // ============================================================================
@ -100,7 +95,7 @@ NyquistEffectsModule::~NyquistEffectsModule()
PluginPath NyquistEffectsModule::GetPath() PluginPath NyquistEffectsModule::GetPath()
{ {
return mPath; return {};
} }
ComponentInterfaceSymbol NyquistEffectsModule::GetSymbol() ComponentInterfaceSymbol NyquistEffectsModule::GetSymbol()

View File

@ -21,7 +21,7 @@
class NyquistEffectsModule final : public ModuleInterface class NyquistEffectsModule final : public ModuleInterface
{ {
public: public:
NyquistEffectsModule(const wxString *path); NyquistEffectsModule();
virtual ~NyquistEffectsModule(); virtual ~NyquistEffectsModule();
// ComponentInterface implementation // ComponentInterface implementation
@ -53,9 +53,4 @@ public:
ComponentInterface *CreateInstance(const PluginPath & path) override; ComponentInterface *CreateInstance(const PluginPath & path) override;
void DeleteInstance(ComponentInterface *instance) override; void DeleteInstance(ComponentInterface *instance) override;
// NyquistEffectModule implementation
private:
PluginPath mPath;
}; };

View File

@ -38,7 +38,7 @@ DECLARE_MODULE_ENTRY(AudacityModule)
{ {
// Create and register the importer // Create and register the importer
// Trust the module manager not to leak this // Trust the module manager not to leak this
return safenew VampEffectsModule(path); return safenew VampEffectsModule();
} }
// ============================================================================ // ============================================================================
@ -52,12 +52,8 @@ DECLARE_BUILTIN_MODULE(VampsEffectBuiltin);
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
VampEffectsModule::VampEffectsModule(const wxString *path) VampEffectsModule::VampEffectsModule()
{ {
if (path)
{
mPath = *path;
}
} }
VampEffectsModule::~VampEffectsModule() VampEffectsModule::~VampEffectsModule()
@ -70,7 +66,7 @@ VampEffectsModule::~VampEffectsModule()
PluginPath VampEffectsModule::GetPath() PluginPath VampEffectsModule::GetPath()
{ {
return mPath; return {};
} }
ComponentInterfaceSymbol VampEffectsModule::GetSymbol() ComponentInterfaceSymbol VampEffectsModule::GetSymbol()

View File

@ -29,7 +29,7 @@
class VampEffectsModule final : public ModuleInterface class VampEffectsModule final : public ModuleInterface
{ {
public: public:
VampEffectsModule(const wxString *path); VampEffectsModule();
virtual ~VampEffectsModule(); virtual ~VampEffectsModule();
// ComponentInterface implementation // ComponentInterface implementation
@ -67,9 +67,6 @@ private:
std::unique_ptr<Vamp::Plugin> FindPlugin(const PluginPath & wpath, std::unique_ptr<Vamp::Plugin> FindPlugin(const PluginPath & wpath,
int & output, int & output,
bool & hasParameters); bool & hasParameters);
private:
PluginPath mPath;
}; };
#endif #endif