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 "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 985 of file AudacityApp.cpp.

◆ ID_IPC_SOCKET

#define ID_IPC_SOCKET   6201

Definition at line 986 of file AudacityApp.cpp.

◆ IPC_APPL

#define IPC_APPL   wxT("audacity")

Definition at line 807 of file AudacityApp.cpp.

◆ IPC_TOPIC

#define IPC_TOPIC   wxT("System")

Definition at line 808 of file AudacityApp.cpp.

◆ kAudacityAppTimerID

#define kAudacityAppTimerID   0

Definition at line 989 of file AudacityApp.cpp.

◆ WL

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

Definition at line 1158 of file AudacityApp.cpp.

Function Documentation

◆ CloseAllProjects()

static bool CloseAllProjects ( bool  force)
static

Definition at line 517 of file AudacityApp.cpp.

518{
520 auto cleanup = finally([]{ ProjectManager::SetClosingAll(false); });
521 while (AllProjects{}.size())
522 {
523 // Closing the project has global side-effect
524 // of deletion from gAudacityProjects
525 if ( force )
526 {
527 GetProjectFrame( **AllProjects{}.begin() ).Close(true);
528 }
529 else
530 {
531 if (! GetProjectFrame( **AllProjects{}.begin() ).Close())
532 return false;
533 }
534 }
535 return true;
536}
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 1018 of file AudacityApp.cpp.

1032 {
1033 // Most of the checks below are copied from ProjectManager::OpenFiles.
1034 // - some rationalisation might be possible.
1035
1036 auto pProj = GetActiveProject().lock();
1037 auto proj = pProj.get();
1038
1039 if (!fullPathStr.empty())
1040 {
1041 // verify that the file exists
1042 if (wxFile::Exists(fullPathStr))
1043 {
1044 FileNames::UpdateDefaultPath(FileNames::Operation::Open, ::wxPathOnly(fullPathStr));
1045
1046 // Make sure it isn't already open.
1047 // Test here even though AudacityProject::OpenFile() also now checks, because
1048 // that method does not return the bad result.
1049 // That itself may be a FIXME.
1050 if (ProjectFileManager::IsAlreadyOpen(fullPathStr))
1051 return false;
1052
1054 ( void ) ProjectManager::OpenProject( proj, fullPathStr,
1055 true /* addtohistory */, false /* reuseNonemptyProject */ );
1056 }
1057 else {
1058 // File doesn't exist - remove file from history
1060 XO(
1061"%s could not be found.\n\nIt has been removed from the list of recent files.")
1062 .Format(fullPathStr) );
1063 return(false);
1064 }
1065 }
1066 return(true);
1067}
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 869 of file AudacityApp.cpp.

870{
871 wxDISABLE_DEBUG_SUPPORT();
872
875
877 {
878 sOSXIsGUIApplication = false;
879 ProcessSerialNumber psn = { 0, kCurrentProcess };
880 TransformProcessType(&psn, kProcessTransformToUIElementApplication);
881 }
882
883 return wxEntry(argc, argv);
884}
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 611 of file AudacityApp.cpp.

612{
613 QuitAudacity(false);
614}
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 538 of file AudacityApp.cpp.

539{
540 // guard against recursion
541 if (gIsQuitting)
542 return;
543
544 gIsQuitting = true;
545
546 wxTheApp->SetExitOnFrameDelete(true);
547
548 // Try to close each open window. If the user hits Cancel
549 // in a Save Changes dialog, don't continue.
550 // BG: unless force is true
551
552 // BG: Are there any projects open?
553 //- if (!AllProjects{}.empty())
554/*start+*/
555 if (AllProjects{}.empty())
556 {
557#ifdef __WXMAC__
559#endif
560 }
561 else
562/*end+*/
563 {
564 if (AllProjects{}.size())
565 // PRL: Always did at least once before close might be vetoed
566 // though I don't know why that is important
568 bool closedAll = CloseAllProjects( bForce );
569 if ( !closedAll )
570 {
571 gIsQuitting = false;
572 return;
573 }
574 }
575
577
578#ifdef EXPERIMENTAL_SCOREALIGN
579 CloseScoreAlignDialog();
580#endif
581
582 // Logger window is always destroyed on macOS,
583 // on other platforms - it prevents the runloop
584 // termination when exiting is requested
585 #if !defined(__WXMAC__)
588 #endif
589
590 //print out profile if we have one by deleting it
591 //temporarily commented out till it is added to all projects
592 //DELETE Profiler::Instance();
593
594 // Save last log for diagnosis
595 auto logger = AudacityLogger::Get();
596 if (logger)
597 {
598 wxFileName logFile(FileNames::DataDir(), wxT("lastlog.txt"));
599 logger->SaveLog(logFile.GetFullPath());
600 }
601
602 //remove our logger
603 std::unique_ptr<wxLog>{ wxLog::SetActiveTarget(NULL) }; // DELETE
604
605 if (bForce)
606 {
607 wxExit();
608 }
609}
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 1828 of file AudacityApp.cpp.

1828 {
1829 // don't allow path of "".
1830 if( dir.empty() )
1831 return;
1832 if( wxDirExists( dir ) ){
1833 result = dir;
1834 return;
1835 }
1836 // Use '/' so that this works on Mac and Windows alike.
1837 wxFileName name( dir + "/junkname.cfg" );
1838 if( name.Mkdir( wxS_DIR_DEFAULT , wxPATH_MKDIR_FULL ) )
1839 result = dir;
1840}
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 2754 of file AudacityApp.cpp.

◆ gConfig

std::shared_ptr<wxConfigBase> gConfig
static

Definition at line 515 of file AudacityApp.cpp.

Referenced by AudacityApp::CleanUp().

◆ gInited

bool gInited = false
static

◆ gIsQuitting

bool gIsQuitting = false
static

Definition at line 509 of file AudacityApp.cpp.

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

◆ ofqueue

wxArrayString ofqueue
static