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 "effects/RegisterBuiltinEffects.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 986 of file AudacityApp.cpp.

◆ ID_IPC_SOCKET

#define ID_IPC_SOCKET   6201

Definition at line 987 of file AudacityApp.cpp.

◆ IPC_APPL

#define IPC_APPL   wxT("audacity")

Definition at line 808 of file AudacityApp.cpp.

◆ IPC_TOPIC

#define IPC_TOPIC   wxT("System")

Definition at line 809 of file AudacityApp.cpp.

◆ kAudacityAppTimerID

#define kAudacityAppTimerID   0

Definition at line 990 of file AudacityApp.cpp.

◆ WL

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

Definition at line 1159 of file AudacityApp.cpp.

Function Documentation

◆ CloseAllProjects()

static bool CloseAllProjects ( bool  force)
static

Definition at line 518 of file AudacityApp.cpp.

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

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

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

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

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

1889 {
1890 // don't allow path of "".
1891 if( dir.empty() )
1892 return;
1893 if( wxDirExists( dir ) ){
1894 result = dir;
1895 return;
1896 }
1897 // Use '/' so that this works on Mac and Windows alike.
1898 wxFileName name( dir + "/junkname.cfg" );
1899 if( name.Mkdir( wxS_DIR_DEFAULT , wxPATH_MKDIR_FULL ) )
1900 result = dir;
1901}
wxString name
Definition: TagsEditor.cpp:166

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

◆ gConfig

std::shared_ptr<wxConfigBase> gConfig
static

Definition at line 516 of file AudacityApp.cpp.

Referenced by AudacityApp::CleanUp().

◆ gInited

bool gInited = false
static

◆ gIsQuitting

bool gIsQuitting = false
static

Definition at line 510 of file AudacityApp.cpp.

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

◆ ofqueue

wxArrayString ofqueue
static