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

Don't call QuitAudacity directly from src/menus...

... This cuts link dependency on AudacityApp.cpp, and allows the function to
be private to that file
This commit is contained in:
Paul Licameli 2019-04-26 00:43:17 -04:00
parent 187e3be0d6
commit 6cde697a8e
6 changed files with 19 additions and 12 deletions

View File

@ -109,9 +109,6 @@
class wxWindow;
void QuitAudacity(bool bForce);
void QuitAudacity();
// Please try to support unlimited path length instead of using PLATFORM_MAX_PATH!
// Define one constant for maximum path value, so we don't have to do
// platform-specific conditionals everywhere we want to check it.

View File

@ -266,7 +266,7 @@ static void wxOnAssert(const wxChar *fileName, int lineNumber, const wxChar *msg
static bool gInited = false;
static bool gIsQuitting = false;
void QuitAudacity(bool bForce)
static void QuitAudacity(bool bForce)
{
// guard against recursion
if (gIsQuitting)
@ -323,7 +323,7 @@ void QuitAudacity(bool bForce)
}
}
void QuitAudacity()
static void QuitAudacity()
{
QuitAudacity(false);
}
@ -647,9 +647,14 @@ BEGIN_EVENT_TABLE(AudacityApp, wxApp)
EVT_MENU(wxID_OPEN, AudacityApp::OnMenuOpen)
EVT_MENU(wxID_ABOUT, AudacityApp::OnMenuAbout)
EVT_MENU(wxID_PREFERENCES, AudacityApp::OnMenuPreferences)
EVT_MENU(wxID_EXIT, AudacityApp::OnMenuExit)
#endif
// Associate the handler with the menu id on all operating systems, even
// if they don't have an application menu bar like in macOS, so that
// other parts of the program can send the application a shut-down
// event
EVT_MENU(wxID_EXIT, AudacityApp::OnMenuExit)
#ifndef __WXMSW__
EVT_SOCKET(ID_IPC_SERVER, AudacityApp::OnServerEvent)
EVT_SOCKET(ID_IPC_SOCKET, AudacityApp::OnSocketEvent)

View File

@ -39,9 +39,6 @@ class AppCommandEvent;
class AudacityLogger;
class AudacityProject;
void QuitAudacity(bool bForce);
void QuitAudacity();
class AliasBlockFile;
class AudacityApp final : public wxApp {

View File

@ -2784,7 +2784,9 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event)
#if !defined(__WXMAC__)
if (quitOnClose) {
QuitAudacity();
// Simulate the application Exit menu item
wxCommandEvent evt{ wxEVT_MENU, wxID_EXIT };
wxTheApp->AddPendingEvent( evt );
}
else {
AllProjects::Reset();

View File

@ -542,7 +542,9 @@ void OnPrint(const CommandContext &context)
void OnExit(const CommandContext &WXUNUSED(context) )
{
QuitAudacity();
// Simulate the application Exit menu item
wxCommandEvent evt{ wxEVT_MENU, wxID_EXIT };
wxTheApp->AddPendingEvent( evt );
}
}; // struct Handler

View File

@ -457,7 +457,11 @@ void OnTimerRecord(const CommandContext &context)
// No action required
break;
case POST_TIMER_RECORD_CLOSE:
wxTheApp->CallAfter( []{ QuitAudacity(); } );
wxTheApp->CallAfter( []{
// Simulate the application Exit menu item
wxCommandEvent evt{ wxEVT_MENU, wxID_EXIT };
wxTheApp->AddPendingEvent( evt );
} );
break;
case POST_TIMER_RECORD_RESTART:
// Restart System