mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-31 07:59:27 +02:00
Complementary un-registration of providers; change function name
This commit is contained in:
parent
64bbc31c54
commit
861470dd77
@ -164,12 +164,15 @@ static ModuleInterface * name(const wxString *path)
|
||||
// Provides the base for embedded module registration. If used, a Register()
|
||||
// method must be supplied explicitly.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define DECLARE_BUILTIN_MODULE_BASE(name) \
|
||||
class name \
|
||||
{ \
|
||||
public: \
|
||||
name() {Register();} \
|
||||
~name() {Unregister();} \
|
||||
void Register(); \
|
||||
void Unregister(); \
|
||||
}; \
|
||||
static name name ## _instance;
|
||||
|
||||
@ -181,7 +184,11 @@ static name name ## _instance;
|
||||
DECLARE_BUILTIN_MODULE_BASE(name) \
|
||||
void name::Register() \
|
||||
{ \
|
||||
RegisterBuiltinModule(MODULE_ENTRY); \
|
||||
RegisterProvider(MODULE_ENTRY); \
|
||||
} \
|
||||
void name::Unregister() \
|
||||
{ \
|
||||
UnregisterProvider(MODULE_ENTRY); \
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -182,13 +182,23 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterBuiltinModule(ModuleMain moduleMain)
|
||||
void RegisterProvider(ModuleMain moduleMain)
|
||||
{
|
||||
builtinModuleList().push_back(moduleMain);
|
||||
auto &list = builtinModuleList();
|
||||
if ( moduleMain )
|
||||
list.push_back(moduleMain);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void UnregisterProvider(ModuleMain moduleMain)
|
||||
{
|
||||
auto &list = builtinModuleList();
|
||||
auto end = list.end(), iter = std::find(list.begin(), end, moduleMain);
|
||||
if (iter != end)
|
||||
list.erase(iter);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Creation/Destruction
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -136,6 +136,13 @@ private:
|
||||
using ModuleMain = ModuleInterface *(*)(const wxString *path);
|
||||
|
||||
AUDACITY_DLL_API
|
||||
void RegisterBuiltinModule(ModuleMain rtn);
|
||||
void RegisterProvider(ModuleMain rtn);
|
||||
AUDACITY_DLL_API
|
||||
void UnregisterProvider(ModuleMain rtn);
|
||||
|
||||
// Guarantee the registry exists before any registrations, so it will
|
||||
// be destroyed only after the un-registrations
|
||||
static struct Init{
|
||||
Init() { RegisterProvider(nullptr); } } sInitBuiltinModules;
|
||||
|
||||
#endif /* __AUDACITY_MODULEMANAGER_H__ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user