1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-15 15:11:12 +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

@@ -136,28 +136,13 @@ const wxChar * GetVersionString()
return AUDACITY_VERSION_STRING;
}
// This is the function that connects us to Audacity.
extern int DLL_API ModuleDispatch(ModuleDispatchTypes type);
int ModuleDispatch(ModuleDispatchTypes type)
{
switch (type)
{
case AppInitialized:
break;
case AppQuiting:
break;
default:
break;
}
return 1;
}
// Register our extra menu items
namespace {
void RegisterMenuItems()
{
// Get here only after the module version check passes
using namespace MenuTable;
// We add two new commands into the Analyze menu.
AttachedItem sAttachment{ wxT("Analyze"),
static AttachedItem sAttachment{ wxT("Analyze"),
( FinderScope( ident ), Section( wxT("NullModule"),
Command(
_T("A New Command"), // internal name
@@ -172,6 +157,27 @@ namespace {
) )
};
}
}
// This is the function that connects us to Audacity.
extern int DLL_API ModuleDispatch(ModuleDispatchTypes type);
int ModuleDispatch(ModuleDispatchTypes type)
{
switch (type)
{
case ModuleInitialize:
RegisterMenuItems();
break;
case AppInitialized:
break;
case AppQuiting:
break;
default:
break;
}
return 1;
}
//Example code commented out.
#if 0

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
//----------------------------------------------------------------------------