Audacity 3.2.0
Classes | Namespaces | Macros | Functions | Variables
AudacityApp.cpp File Reference
#include "AudacityApp.h"
#include <wx/setup.h>
#include <wx/wxcrtvararg.h>
#include <wx/defs.h>
#include <wx/evtloop.h>
#include <wx/bitmap.h>
#include <wx/docview.h>
#include <wx/ipc.h>
#include <wx/window.h>
#include <wx/menu.h>
#include <wx/snglinst.h>
#include <wx/splash.h>
#include <wx/stdpaths.h>
#include <wx/sysopt.h>
#include <wx/fontmap.h>
#include <wx/fs_zip.h>
#include <wx/dir.h>
#include <wx/file.h>
#include <wx/filename.h>
#include <unistd.h>
#include <wx/msw/registry.h>
#include "AudacityLogger.h"
#include "AboutDialog.h"
#include "ActiveProject.h"
#include "AColor.h"
#include "AudacityFileConfig.h"
#include "AudioIO.h"
#include "Benchmark.h"
#include "Clipboard.h"
#include "CommandLineArgs.h"
#include "CrashReport.h"
#include "commands/CommandHandler.h"
#include "commands/AppCommandEvent.h"
#include "widgets/ASlider.h"
#include "Journal.h"
#include "Languages.h"
#include "MenuCreator.h"
#include "PathList.h"
#include "PendingTracks.h"
#include "PluginManager.h"
#include "Project.h"
#include "ProjectAudioIO.h"
#include "ProjectAudioManager.h"
#include "ProjectFileIO.h"
#include "ProjectFileManager.h"
#include "ProjectHistory.h"
#include "ProjectManager.h"
#include "ProjectSettings.h"
#include "ProjectWindow.h"
#include "ProjectWindows.h"
#include "Sequence.h"
#include "SelectFile.h"
#include "TempDirectory.h"
#include "LoadThemeResources.h"
#include "Track.h"
#include "prefs/PrefsDialog.h"
#include "Theme.h"
#include "Viewport.h"
#include "PlatformCompatibility.h"
#include "AutoRecoveryDialog.h"
#include "SplashDialog.h"
#include "FFT.h"
#include "AudacityMessageBox.h"
#include "prefs/DirectoriesPrefs.h"
#include "prefs/GUISettings.h"
#include "tracks/ui/Scrubbing.h"
#include "widgets/FileHistory.h"
#include "wxWidgetsBasicUI.h"
#include "LogWindow.h"
#include "FrameStatisticsDialog.h"
#include "PluginStartupRegistration.h"
#include "IncompatiblePluginsDialog.h"
#include "wxWidgetsWindowPlacement.h"
#include "ModuleManager.h"
#include "PluginHost.h"
#include "Import.h"
#include "../images/Audacity-splash.xpm"
#include <thread>
#include "ExportPluginRegistry.h"
#include "SettingsWX.h"
#include "prefs/EffectsPrefs.h"
#include <ApplicationServices/ApplicationServices.h>

Go to the source code of this file.

Classes

class  IPCConn
 
class  IPCServ
 

Namespaces

namespace  anonymous_namespace{AudacityApp.cpp}
 Custom events.
 
namespace  IMPLEMENT_WX_THEME_SUPPORT
 

Macros

#define IPC_APPL   wxT("audacity")
 
#define IPC_TOPIC   wxT("System")
 
#define ID_IPC_SERVER   6200
 
#define ID_IPC_SOCKET   6201
 
#define kAudacityAppTimerID   0
 
#define WL(lang, sublang)   (lang), (sublang),
 

Functions

void anonymous_namespace{AudacityApp.cpp}::PopulatePreferences ()
 
void anonymous_namespace{AudacityApp.cpp}::InitCrashreports ()
 
static bool CloseAllProjects (bool force)
 
static void QuitAudacity (bool bForce)
 
static void QuitAudacity ()
 
int main (int argc, char *argv[])
 
 EVT_MENU_RANGE (FileHistory::ID_RECENT_FIRST, FileHistory::ID_RECENT_LAST, AudacityApp::OnMRUFile) bool AudacityApp
 
void SetToExtantDirectory (wxString &result, const wxString &dir)
 

Variables

static bool gInited = false
 
static bool gIsQuitting = false
 
static std::shared_ptr< wxConfigBase > gConfig
 
static wxArrayString ofqueue
 
bool IMPLEMENT_WX_THEME_SUPPORT::sOSXIsGUIApplication { true }
 
static audacity::ApplicationSettings::Scope applicationSettingsScope
 

Macro Definition Documentation

◆ ID_IPC_SERVER

#define ID_IPC_SERVER   6200

Definition at line 974 of file AudacityApp.cpp.

◆ ID_IPC_SOCKET

#define ID_IPC_SOCKET   6201

Definition at line 975 of file AudacityApp.cpp.

◆ IPC_APPL

#define IPC_APPL   wxT("audacity")

Definition at line 796 of file AudacityApp.cpp.

◆ IPC_TOPIC

#define IPC_TOPIC   wxT("System")

Definition at line 797 of file AudacityApp.cpp.

◆ kAudacityAppTimerID

#define kAudacityAppTimerID   0

Definition at line 978 of file AudacityApp.cpp.

◆ WL

#define WL (   lang,
  sublang 
)    (lang), (sublang),

Definition at line 1147 of file AudacityApp.cpp.

Function Documentation

◆ CloseAllProjects()

static bool CloseAllProjects ( bool  force)
static

Definition at line 506 of file AudacityApp.cpp.

507{
509 auto cleanup = finally([]{ ProjectManager::SetClosingAll(false); });
510 while (AllProjects{}.size())
511 {
512 // Closing the project has global side-effect
513 // of deletion from gAudacityProjects
514 if ( force )
515 {
516 GetProjectFrame( **AllProjects{}.begin() ).Close(true);
517 }
518 else
519 {
520 if (! GetProjectFrame( **AllProjects{}.begin() ).Close())
521 return false;
522 }
523 }
524 return true;
525}
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
size_t size() const
Definition: Project.cpp:17
const_iterator begin() const
Definition: Project.cpp:22
static void SetClosingAll(bool closing)

References AllProjects::begin(), GetProjectFrame(), ProjectManager::SetClosingAll(), and AllProjects::size().

Referenced by AudacityApp::OnEndSession(), and QuitAudacity().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EVT_MENU_RANGE()

proj may be null

Definition at line 1007 of file AudacityApp.cpp.

1021 {
1022 // Most of the checks below are copied from ProjectManager::OpenFiles.
1023 // - some rationalisation might be possible.
1024
1025 auto pProj = GetActiveProject().lock();
1026 auto proj = pProj.get();
1027
1028 if (!fullPathStr.empty())
1029 {
1030 // verify that the file exists
1031 if (wxFile::Exists(fullPathStr))
1032 {
1033 FileNames::UpdateDefaultPath(FileNames::Operation::Open, ::wxPathOnly(fullPathStr));
1034
1035 // Make sure it isn't already open.
1036 // Test here even though AudacityProject::OpenFile() also now checks, because
1037 // that method does not return the bad result.
1038 // That itself may be a FIXME.
1039 if (ProjectFileManager::IsAlreadyOpen(fullPathStr))
1040 return false;
1041
1043 ( void ) ProjectManager::OpenProject( proj, fullPathStr,
1044 true /* addtohistory */, false /* reuseNonemptyProject */ );
1045 }
1046 else {
1047 // File doesn't exist - remove file from history
1049 XO(
1050"%s could not be found.\n\nIt has been removed from the list of recent files.")
1051 .Format(fullPathStr) );
1052 return(false);
1053 }
1054 }
1055 return(true);
1056}
AUDACITY_DLL_API std::weak_ptr< AudacityProject > GetActiveProject()
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
XO("Cut/Copy/Paste")
Abstract base class used in importing a file.
static bool IsAlreadyOpen(const FilePath &projPathName)
static AudacityProject * OpenProject(AudacityProject *pGivenProject, const FilePath &fileNameArg, bool addtohistory, bool reuseNonemptyProject)
Open a file into an AudacityProject, returning the project, or nullptr for failure.
FILES_API void UpdateDefaultPath(Operation op, const FilePath &path)

References AudacityMessageBox(), GetActiveProject(), ProjectFileManager::IsAlreadyOpen(), ProjectManager::OpenProject(), FileNames::UpdateDefaultPath(), and XO().

Here is the call graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 858 of file AudacityApp.cpp.

859{
860 wxDISABLE_DEBUG_SUPPORT();
861
864
866 {
867 sOSXIsGUIApplication = false;
868 ProcessSerialNumber psn = { 0, kCurrentProcess };
869 TransformProcessType(&psn, kProcessTransformToUIElementApplication);
870 }
871
872 return wxEntry(argc, argv);
873}
static bool IsHostProcess()
Returns true if current process is considered to be a plugin host process.
Definition: PluginHost.cpp:202
UTILITY_API const char *const * argv
A copy of argv; responsibility of application startup to assign it.
UTILITY_API int argc
A copy of argc; responsibility of application startup to assign it.

References CommandLineArgs::argc, CommandLineArgs::argv, PluginHost::IsHostProcess(), and IMPLEMENT_WX_THEME_SUPPORT::sOSXIsGUIApplication.

Referenced by ToolDock::VisitLayout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ QuitAudacity() [1/2]

static void QuitAudacity ( )
static

Definition at line 600 of file AudacityApp.cpp.

601{
602 QuitAudacity(false);
603}
static void QuitAudacity(bool bForce)

References QuitAudacity().

Here is the call graph for this function:

◆ QuitAudacity() [2/2]

static void QuitAudacity ( bool  bForce)
static

Definition at line 527 of file AudacityApp.cpp.

528{
529 // guard against recursion
530 if (gIsQuitting)
531 return;
532
533 gIsQuitting = true;
534
535 wxTheApp->SetExitOnFrameDelete(true);
536
537 // Try to close each open window. If the user hits Cancel
538 // in a Save Changes dialog, don't continue.
539 // BG: unless force is true
540
541 // BG: Are there any projects open?
542 //- if (!AllProjects{}.empty())
543/*start+*/
544 if (AllProjects{}.empty())
545 {
546#ifdef __WXMAC__
548#endif
549 }
550 else
551/*end+*/
552 {
553 if (AllProjects{}.size())
554 // PRL: Always did at least once before close might be vetoed
555 // though I don't know why that is important
557 bool closedAll = CloseAllProjects( bForce );
558 if ( !closedAll )
559 {
560 gIsQuitting = false;
561 return;
562 }
563 }
564
566
567#ifdef EXPERIMENTAL_SCOREALIGN
568 CloseScoreAlignDialog();
569#endif
570
571 // Logger window is always destroyed on macOS,
572 // on other platforms - it prevents the runloop
573 // termination when exiting is requested
574 #if !defined(__WXMAC__)
577 #endif
578
579 //print out profile if we have one by deleting it
580 //temporarily commented out till it is added to all projects
581 //DELETE Profiler::Instance();
582
583 // Save last log for diagnosis
584 auto logger = AudacityLogger::Get();
585 if (logger)
586 {
587 wxFileName logFile(FileNames::DataDir(), wxT("lastlog.txt"));
588 logger->SaveLog(logFile.GetFullPath());
589 }
590
591 //remove our logger
592 std::unique_ptr<wxLog>{ wxLog::SetActiveTarget(NULL) }; // DELETE
593
594 if (bForce)
595 {
596 wxExit();
597 }
598}
wxT("CloseDown"))
static bool gIsQuitting
static bool CloseAllProjects(bool force)
@ AppQuiting
bool empty() const
Definition: Project.h:47
static AudacityLogger * Get()
static Clipboard & Get()
Definition: Clipboard.cpp:28
void Clear()
Definition: Clipboard.cpp:40
static void Destroy()
Destroys the dialog to prevent Audacity from hanging on exit.
static void Destroy()
Destroys the log window (if any)
Definition: LogWindow.cpp:178
static ModuleManager & Get()
int Dispatch(ModuleDispatchTypes type)
static void SaveWindowSize()
FILES_API FilePath DataDir()
Audacity user data directory.

References AppQuiting, Clipboard::Clear(), CloseAllProjects(), FileNames::DataDir(), LogWindow::Destroy(), FrameStatisticsDialog::Destroy(), ModuleManager::Dispatch(), AllProjects::empty(), AudacityLogger::Get(), ModuleManager::Get(), Clipboard::Get(), gIsQuitting, ProjectManager::SaveWindowSize(), AllProjects::size(), and wxT().

Referenced by AudacityApp::InitPart2(), AudacityApp::OnInit0(), AudacityApp::OnMenuExit(), and QuitAudacity().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetToExtantDirectory()

void SetToExtantDirectory ( wxString &  result,
const wxString &  dir 
)

Definition at line 1815 of file AudacityApp.cpp.

1815 {
1816 // don't allow path of "".
1817 if( dir.empty() )
1818 return;
1819 if( wxDirExists( dir ) ){
1820 result = dir;
1821 return;
1822 }
1823 // Use '/' so that this works on Mac and Windows alike.
1824 wxFileName name( dir + "/junkname.cfg" );
1825 if( name.Mkdir( wxS_DIR_DEFAULT , wxPATH_MKDIR_FULL ) )
1826 result = dir;
1827}
const TranslatableString name
Definition: Distortion.cpp:76

References name.

Referenced by AudacityApp::InitTempDir().

Here is the caller graph for this function:

Variable Documentation

◆ applicationSettingsScope

audacity::ApplicationSettings::Scope applicationSettingsScope
static
Initial value:
{
[]{
static std::once_flag configSetupFlag;
std::call_once(configSetupFlag, [&]{
const auto configFileName = wxFileName { FileNames::Configuration() };
wxTheApp->GetAppName(), wxEmptyString,
configFileName.GetFullPath(),
wxEmptyString, wxCONFIG_USE_LOCAL_FILE);
wxConfigBase::Set(gConfig.get());
});
return std::make_unique<SettingsWX>(gConfig);
}
}
static std::shared_ptr< wxConfigBase > gConfig
static std::unique_ptr< AudacityFileConfig > Create(const wxString &appName={}, const wxString &vendorName={}, const wxString &localFilename={}, const wxString &globalFilename={}, long style=wxCONFIG_USE_LOCAL_FILE|wxCONFIG_USE_GLOBAL_FILE, const wxMBConv &conv=wxConvAuto())
Require a call to this factory, to guarantee proper two-phase initialization.
FILES_API FilePath Configuration()

Definition at line 2741 of file AudacityApp.cpp.

◆ gConfig

std::shared_ptr<wxConfigBase> gConfig
static

Definition at line 504 of file AudacityApp.cpp.

Referenced by AudacityApp::CleanUp().

◆ gInited

bool gInited = false
static

◆ gIsQuitting

bool gIsQuitting = false
static

Definition at line 498 of file AudacityApp.cpp.

Referenced by AudacityApp::OnEndSession(), AudacityApp::OnExit(), and QuitAudacity().

◆ ofqueue

wxArrayString ofqueue
static