1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-18 16:41:14 +02:00

Modules should register their menu items only after version check

This commit is contained in:
Paul Licameli
2020-02-16 13:28:40 -05:00
parent 11bbce10b1
commit 5c85deb944
2 changed files with 49 additions and 37 deletions

View File

@@ -140,15 +140,30 @@ and replace the main project window with our own wxFrame.
*/
namespace {
CommandHandlerObject &findme(AudacityProject&)
{
return *NyqBench::GetBench();
}
void RegisterMenuItems()
{
// Get here only after the module version check passes
using namespace MenuTable;
static AttachedItem sAttachment{ wxT("Tools"),
( FinderScope( findme ), Section( wxT("NyquistWorkBench"),
Command( wxT("NyqBench"), XO("&Nyquist Workbench..."),
static_cast<CommandFunctorPointer>(&NyqBench::ShowNyqBench),
AudioIONotBusyFlag())
) )
};
}
}
extern "C"
{
static NyqBench *gBench = NULL;
static CommandHandlerObject &findme(AudacityProject&)
{
return *NyqBench::GetBench();
}
#ifdef _MSC_VER
#define DLL_API _declspec(dllexport)
#else
@@ -171,6 +186,9 @@ extern "C"
// is called by Audacity to initialize/terminate the module
int ModuleDispatch(ModuleDispatchTypes type){
switch (type){
case ModuleInitialize:
RegisterMenuItems();
break;
case AppQuiting: {
//It is perfectly OK for gBench to be NULL.
//Can happen if the menu item was never invoked.
@@ -188,18 +206,6 @@ extern "C"
}
};
// Register our extra menu item
namespace {
using namespace MenuTable;
AttachedItem sAttachment{ wxT("Tools"),
( FinderScope( findme ), Section( wxT("NyquistWorkBench"),
Command( wxT("NyqBench"), XO("&Nyquist Workbench..."),
static_cast<CommandFunctorPointer>(&NyqBench::ShowNyqBench),
AudioIONotBusyFlag())
) )
};
}
//----------------------------------------------------------------------------
// NyqTextCtrl
//----------------------------------------------------------------------------