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

◆ ID_IPC_SOCKET

#define ID_IPC_SOCKET   6201

Definition at line 968 of file AudacityApp.cpp.

◆ IPC_APPL

#define IPC_APPL   wxT("audacity")

Definition at line 789 of file AudacityApp.cpp.

◆ IPC_TOPIC

#define IPC_TOPIC   wxT("System")

Definition at line 790 of file AudacityApp.cpp.

◆ kAudacityAppTimerID

#define kAudacityAppTimerID   0

Definition at line 971 of file AudacityApp.cpp.

◆ WL

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

Definition at line 1140 of file AudacityApp.cpp.

Function Documentation

◆ CloseAllProjects()

static bool CloseAllProjects ( bool  force)
static

Definition at line 499 of file AudacityApp.cpp.

500{
502 auto cleanup = finally([]{ ProjectManager::SetClosingAll(false); });
503 while (AllProjects{}.size())
504 {
505 // Closing the project has global side-effect
506 // of deletion from gAudacityProjects
507 if ( force )
508 {
509 GetProjectFrame( **AllProjects{}.begin() ).Close(true);
510 }
511 else
512 {
513 if (! GetProjectFrame( **AllProjects{}.begin() ).Close())
514 return false;
515 }
516 }
517 return true;
518}
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 1000 of file AudacityApp.cpp.

1014 {
1015 // Most of the checks below are copied from ProjectManager::OpenFiles.
1016 // - some rationalisation might be possible.
1017
1018 auto pProj = GetActiveProject().lock();
1019 auto proj = pProj.get();
1020
1021 if (!fullPathStr.empty())
1022 {
1023 // verify that the file exists
1024 if (wxFile::Exists(fullPathStr))
1025 {
1026 FileNames::UpdateDefaultPath(FileNames::Operation::Open, ::wxPathOnly(fullPathStr));
1027
1028 // Make sure it isn't already open.
1029 // Test here even though AudacityProject::OpenFile() also now checks, because
1030 // that method does not return the bad result.
1031 // That itself may be a FIXME.
1032 if (ProjectFileManager::IsAlreadyOpen(fullPathStr))
1033 return false;
1034
1036 ( void ) ProjectManager::OpenProject( proj, fullPathStr,
1037 true /* addtohistory */, false /* reuseNonemptyProject */ );
1038 }
1039 else {
1040 // File doesn't exist - remove file from history
1042 XO(
1043"%s could not be found.\n\nIt has been removed from the list of recent files.")
1044 .Format(fullPathStr) );
1045 return(false);
1046 }
1047 }
1048 return(true);
1049}
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 851 of file AudacityApp.cpp.

852{
853 wxDISABLE_DEBUG_SUPPORT();
854
857
859 {
860 sOSXIsGUIApplication = false;
861 ProcessSerialNumber psn = { 0, kCurrentProcess };
862 TransformProcessType(&psn, kProcessTransformToUIElementApplication);
863 }
864
865 return wxEntry(argc, argv);
866}
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 593 of file AudacityApp.cpp.

594{
595 QuitAudacity(false);
596}
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 520 of file AudacityApp.cpp.

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

1806 {
1807 // don't allow path of "".
1808 if( dir.empty() )
1809 return;
1810 if( wxDirExists( dir ) ){
1811 result = dir;
1812 return;
1813 }
1814 // Use '/' so that this works on Mac and Windows alike.
1815 wxFileName name( dir + "/junkname.cfg" );
1816 if( name.Mkdir( wxS_DIR_DEFAULT , wxPATH_MKDIR_FULL ) )
1817 result = dir;
1818}
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 2730 of file AudacityApp.cpp.

◆ gConfig

std::shared_ptr<wxConfigBase> gConfig
static

Definition at line 497 of file AudacityApp.cpp.

Referenced by AudacityApp::CleanUp().

◆ gInited

bool gInited = false
static

◆ gIsQuitting

bool gIsQuitting = false
static

Definition at line 491 of file AudacityApp.cpp.

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

◆ ofqueue

wxArrayString ofqueue
static