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 "FFmpeg.h"
#include "Journal.h"
#include "Languages.h"
#include "Menus.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 "PlatformCompatibility.h"
#include "AutoRecoveryDialog.h"
#include "SplashDialog.h"
#include "FFT.h"
#include "widgets/AudacityMessageBox.h"
#include "prefs/DirectoriesPrefs.h"
#include "prefs/GUISettings.h"
#include "tracks/ui/Scrubbing.h"
#include "FileConfig.h"
#include "widgets/FileHistory.h"
#include "widgets/wxWidgetsBasicUI.h"
#include "LogWindow.h"
#include "FrameStatisticsDialog.h"
#include "PluginStartupRegistration.h"
#include "IncompatiblePluginsDialog.h"
#include "widgets/wxWidgetsWindowPlacement.h"
#include "ModuleManager.h"
#include "PluginHost.h"
#include "import/Import.h"
#include "../images/AudacityLogoWithName.xpm"
#include <thread>
#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 ()
 
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 wxArrayString ofqueue
 
bool IMPLEMENT_WX_THEME_SUPPORT::sOSXIsGUIApplication { true }
 

Macro Definition Documentation

◆ ID_IPC_SERVER

#define ID_IPC_SERVER   6200

Definition at line 925 of file AudacityApp.cpp.

◆ ID_IPC_SOCKET

#define ID_IPC_SOCKET   6201

Definition at line 926 of file AudacityApp.cpp.

◆ IPC_APPL

#define IPC_APPL   wxT("audacity")

Definition at line 747 of file AudacityApp.cpp.

◆ IPC_TOPIC

#define IPC_TOPIC   wxT("System")

Definition at line 748 of file AudacityApp.cpp.

◆ kAudacityAppTimerID

#define kAudacityAppTimerID   0

Definition at line 929 of file AudacityApp.cpp.

◆ WL

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

Definition at line 1098 of file AudacityApp.cpp.

Function Documentation

◆ CloseAllProjects()

static bool CloseAllProjects ( bool  force)
static

Definition at line 465 of file AudacityApp.cpp.

466{
468 auto cleanup = finally([]{ ProjectManager::SetClosingAll(false); });
469 while (AllProjects{}.size())
470 {
471 // Closing the project has global side-effect
472 // of deletion from gAudacityProjects
473 if ( force )
474 {
475 GetProjectFrame( **AllProjects{}.begin() ).Close(true);
476 }
477 else
478 {
479 if (! GetProjectFrame( **AllProjects{}.begin() ).Close())
480 return false;
481 }
482 }
483 return true;
484}
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 958 of file AudacityApp.cpp.

972 {
973 // Most of the checks below are copied from ProjectManager::OpenFiles.
974 // - some rationalisation might be possible.
975
976 auto pProj = GetActiveProject().lock();
977 auto proj = pProj.get();
978
979 if (!fullPathStr.empty())
980 {
981 // verify that the file exists
982 if (wxFile::Exists(fullPathStr))
983 {
984 FileNames::UpdateDefaultPath(FileNames::Operation::Open, ::wxPathOnly(fullPathStr));
985
986 // Make sure it isn't already open.
987 // Test here even though AudacityProject::OpenFile() also now checks, because
988 // that method does not return the bad result.
989 // That itself may be a FIXME.
990 if (ProjectFileManager::IsAlreadyOpen(fullPathStr))
991 return false;
992
994 ( void ) ProjectManager::OpenProject( proj, fullPathStr,
995 true /* addtohistory */, false /* reuseNonemptyProject */ );
996 }
997 else {
998 // File doesn't exist - remove file from history
1000 XO(
1001"%s could not be found.\n\nIt has been removed from the list of recent files.")
1002 .Format(fullPathStr) );
1003 return(false);
1004 }
1005 }
1006 return(true);
1007}
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 809 of file AudacityApp.cpp.

810{
811 wxDISABLE_DEBUG_SUPPORT();
812
815
817 {
818 sOSXIsGUIApplication = false;
819 ProcessSerialNumber psn = { 0, kCurrentProcess };
820 TransformProcessType(&psn, kProcessTransformToUIElementApplication);
821 }
822
823 return wxEntry(argc, argv);
824}
static bool IsHostProcess()
Returns true if current process is considered to be a plugin host process.
Definition: PluginHost.cpp:208
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 559 of file AudacityApp.cpp.

560{
561 QuitAudacity(false);
562}
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 486 of file AudacityApp.cpp.

487{
488 // guard against recursion
489 if (gIsQuitting)
490 return;
491
492 gIsQuitting = true;
493
494 wxTheApp->SetExitOnFrameDelete(true);
495
496 // Try to close each open window. If the user hits Cancel
497 // in a Save Changes dialog, don't continue.
498 // BG: unless force is true
499
500 // BG: Are there any projects open?
501 //- if (!AllProjects{}.empty())
502/*start+*/
503 if (AllProjects{}.empty())
504 {
505#ifdef __WXMAC__
507#endif
508 }
509 else
510/*end+*/
511 {
512 if (AllProjects{}.size())
513 // PRL: Always did at least once before close might be vetoed
514 // though I don't know why that is important
516 bool closedAll = CloseAllProjects( bForce );
517 if ( !closedAll )
518 {
519 gIsQuitting = false;
520 return;
521 }
522 }
523
525
526#ifdef EXPERIMENTAL_SCOREALIGN
527 CloseScoreAlignDialog();
528#endif
529
530 // Logger window is always destroyed on macOS,
531 // on other platforms - it prevents the runloop
532 // termination when exiting is requested
533 #if !defined(__WXMAC__)
536 #endif
537
538 //print out profile if we have one by deleting it
539 //temporarily commented out till it is added to all projects
540 //DELETE Profiler::Instance();
541
542 // Save last log for diagnosis
543 auto logger = AudacityLogger::Get();
544 if (logger)
545 {
546 wxFileName logFile(FileNames::DataDir(), wxT("lastlog.txt"));
547 logger->SaveLog(logFile.GetFullPath());
548 }
549
550 //remove our logger
551 std::unique_ptr<wxLog>{ wxLog::SetActiveTarget(NULL) }; // DELETE
552
553 if (bForce)
554 {
555 wxExit();
556 }
557}
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(), FrameStatisticsDialog::Destroy(), LogWindow::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 1767 of file AudacityApp.cpp.

1767 {
1768 // don't allow path of "".
1769 if( dir.empty() )
1770 return;
1771 if( wxDirExists( dir ) ){
1772 result = dir;
1773 return;
1774 }
1775 // Use '/' so that this works on Mac and Windows alike.
1776 wxFileName name( dir + "/junkname.cfg" );
1777 if( name.Mkdir( wxS_DIR_DEFAULT , wxPATH_MKDIR_FULL ) )
1778 result = dir;
1779}
const TranslatableString name
Definition: Distortion.cpp:74

References name.

Referenced by AudacityApp::InitTempDir().

Here is the caller graph for this function:

Variable Documentation

◆ gInited

bool gInited = false
static

◆ gIsQuitting

bool gIsQuitting = false
static

Definition at line 463 of file AudacityApp.cpp.

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

◆ ofqueue

wxArrayString ofqueue
static