mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-23 17:30:17 +01:00
Complementary un-registration of providers; change function name
This commit is contained in:
@@ -164,12 +164,15 @@ static ModuleInterface * name(const wxString *path)
|
|||||||
// Provides the base for embedded module registration. If used, a Register()
|
// Provides the base for embedded module registration. If used, a Register()
|
||||||
// method must be supplied explicitly.
|
// method must be supplied explicitly.
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#define DECLARE_BUILTIN_MODULE_BASE(name) \
|
#define DECLARE_BUILTIN_MODULE_BASE(name) \
|
||||||
class name \
|
class name \
|
||||||
{ \
|
{ \
|
||||||
public: \
|
public: \
|
||||||
name() {Register();} \
|
name() {Register();} \
|
||||||
|
~name() {Unregister();} \
|
||||||
void Register(); \
|
void Register(); \
|
||||||
|
void Unregister(); \
|
||||||
}; \
|
}; \
|
||||||
static name name ## _instance;
|
static name name ## _instance;
|
||||||
|
|
||||||
@@ -181,7 +184,11 @@ static name name ## _instance;
|
|||||||
DECLARE_BUILTIN_MODULE_BASE(name) \
|
DECLARE_BUILTIN_MODULE_BASE(name) \
|
||||||
void name::Register() \
|
void name::Register() \
|
||||||
{ \
|
{ \
|
||||||
RegisterBuiltinModule(MODULE_ENTRY); \
|
RegisterProvider(MODULE_ENTRY); \
|
||||||
|
} \
|
||||||
|
void name::Unregister() \
|
||||||
|
{ \
|
||||||
|
UnregisterProvider(MODULE_ENTRY); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#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;
|
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
|
// Creation/Destruction
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -136,6 +136,13 @@ private:
|
|||||||
using ModuleMain = ModuleInterface *(*)(const wxString *path);
|
using ModuleMain = ModuleInterface *(*)(const wxString *path);
|
||||||
|
|
||||||
AUDACITY_DLL_API
|
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__ */
|
#endif /* __AUDACITY_MODULEMANAGER_H__ */
|
||||||
|
|||||||
Reference in New Issue
Block a user