Audacity  2.2.2
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
AudacityApp Class Referencefinal

AudacityApp is the 'main' class for Audacity. More...

#include <AudacityApp.h>

Inheritance diagram for AudacityApp:

Public Member Functions

 AudacityApp ()
 
 ~AudacityApp ()
 
bool OnInit (void) override
 
int OnExit (void) override
 
void OnFatalException () override
 
bool OnExceptionInMainLoop () override
 
int FilterEvent (wxEvent &event) override
 
wxString InitLang (const wxString &lang)
 
void OnMenuAbout (wxCommandEvent &event)
 
void OnMenuNew (wxCommandEvent &event)
 
void OnMenuOpen (wxCommandEvent &event)
 
void OnMenuPreferences (wxCommandEvent &event)
 
void OnMenuExit (wxCommandEvent &event)
 
void OnQueryEndSession (wxCloseEvent &event)
 
void OnEndSession (wxCloseEvent &event)
 
void OnMRUClear (wxCommandEvent &event)
 
void OnMRUFile (wxCommandEvent &event)
 
bool MRUOpen (const wxString &fileName)
 
bool SafeMRUOpen (const wxString &fileName)
 
void OnReceiveCommand (AppCommandEvent &event)
 
void OnKeyDown (wxKeyEvent &event)
 
void OnTimer (wxTimerEvent &event)
 
void OnServerEvent (wxSocketEvent &evt)
 
void OnSocketEvent (wxSocketEvent &evt)
 
void MarkAliasedFilesMissingWarning (const AliasBlockFile *b)
 Mark playback as having missing aliased blockfiles. More...
 
void SetMissingAliasedFileWarningShouldShow (bool b)
 Changes the behavior of missing aliased blockfiles warnings. More...
 
bool ShouldShowMissingAliasedFileWarning ()
 Returns true if the user should be notified of missing alias warnings. More...
 
FileHistoryGetRecentFiles ()
 
void AddFileToHistory (const wxString &name)
 
bool GetWindowRectAlreadySaved () const
 
void SetWindowRectAlreadySaved (bool alreadySaved)
 
AudacityLoggerGetLogger ()
 
void SetVersionKeysInit (int major, int minor, int micro)
 
void GetVersionKeysInit (int &major, int &minor, int &micro) const
 

Static Public Member Functions

static void AddUniquePathToPathList (const wxString &path, wxArrayString &pathList)
 
static void AddMultiPathsToPathList (const wxString &multiPathString, wxArrayString &pathList)
 
static void FindFilesInPathList (const wxString &pattern, const wxArrayString &pathList, wxArrayString &results, int flags=wxDIR_FILES)
 
static bool IsTempDirectoryNameOK (const wxString &Name)
 

Public Attributes

wxArrayString audacityPathList
 A list of directories that should be searched for Audacity files (plug-ins, help files, etc.). More...
 
wxString defaultTempDir
 Default temp directory. More...
 

Private Member Functions

void InitCommandHandler ()
 
bool InitTempDir ()
 
bool CreateSingleInstanceChecker (const wxString &dir)
 
std::unique_ptr< wxCmdLineParser > ParseCommandLine ()
 

Private Attributes

std::unique_ptr< CommandHandlermCmdHandler
 
std::unique_ptr< FileHistorymRecentFiles
 
std::unique_ptr< wxLocale > mLocale
 
std::unique_ptr
< wxSingleInstanceChecker > 
mChecker
 
wxTimer mTimer
 
bool m_aliasMissingWarningShouldShow
 
std::weak_ptr< AudacityProjectm_LastMissingBlockFileProject
 
wxString m_LastMissingBlockFilePath
 
ODLock m_LastMissingBlockFileLock
 
bool mWindowRectAlreadySaved
 
std::unique_ptr< wxSocketServer > mIPCServ
 
int mVersionMajorKeyInit {}
 
int mVersionMinorKeyInit {}
 
int mVersionMicroKeyInit {}
 

Detailed Description

AudacityApp is the 'main' class for Audacity.

It handles initialization and termination by subclassing wxApp.

Definition at line 59 of file AudacityApp.h.

Constructor & Destructor Documentation

AudacityApp::AudacityApp ( )

Definition at line 1214 of file AudacityApp.cpp.

1215 {
1216 // Do not capture crashes in debug builds
1217 #if !defined(__WXDEBUG__)
1218 #if defined(EXPERIMENTAL_CRASH_REPORT)
1219 #if defined(wxUSE_ON_FATAL_EXCEPTION) && wxUSE_ON_FATAL_EXCEPTION
1220  wxHandleFatalExceptions();
1221 #endif
1222 #endif
1223 #endif
1224 }
AudacityApp::~AudacityApp ( )

Definition at line 1226 of file AudacityApp.cpp.

1227 {
1228 }

Member Function Documentation

void AudacityApp::AddFileToHistory ( const wxString &  name)

Definition at line 2139 of file AudacityApp.cpp.

References mRecentFiles.

Referenced by MacroCommands::BuildCleanFileName(), AudacityProject::Import(), AudacityProject::OpenFile(), AudacityProject::SaveAs(), and AudacityProject::SaveFromTimerRecording().

2140 {
2141  mRecentFiles->AddFileToHistory(name);
2142 }
const wxChar * name
Definition: Distortion.cpp:94
std::unique_ptr< FileHistory > mRecentFiles
Definition: AudacityApp.h:180
void AudacityApp::AddMultiPathsToPathList ( const wxString &  multiPathString,
wxArrayString &  pathList 
)
static

Definition at line 2072 of file AudacityApp.cpp.

References AddUniquePathToPathList().

Referenced by ModuleManager::DiscoverProviders(), ModuleManager::Initialize(), and OnInit().

2074 {
2075  wxString multiPathString(multiPathStringArg);
2076  while (multiPathString != wxT("")) {
2077  wxString onePath = multiPathString.BeforeFirst(wxPATH_SEP[0]);
2078  multiPathString = multiPathString.AfterFirst(wxPATH_SEP[0]);
2079  AddUniquePathToPathList(onePath, pathList);
2080  }
2081 }
static void AddUniquePathToPathList(const wxString &path, wxArrayString &pathList)
void AudacityApp::AddUniquePathToPathList ( const wxString &  path,
wxArrayString &  pathList 
)
static

Definition at line 2056 of file AudacityApp.cpp.

Referenced by AddMultiPathsToPathList(), ModuleManager::DiscoverProviders(), GetLanguages(), NyquistEffect::GetNyquistSearchPath(), ModuleManager::Initialize(), and OnInit().

2058 {
2059  wxFileName pathNorm = pathArg;
2060  pathNorm.Normalize();
2061  const wxString newpath{ pathNorm.GetFullPath() };
2062 
2063  for(unsigned int i=0; i<pathList.GetCount(); i++) {
2064  if (wxFileName(newpath) == wxFileName(pathList[i]))
2065  return;
2066  }
2067 
2068  pathList.Add(newpath);
2069 }
bool AudacityApp::CreateSingleInstanceChecker ( const wxString &  dir)
private

Definition at line 1821 of file AudacityApp.cpp.

References _(), AudacityMessageBox(), ID_IPC_SERVER, IPC_APPL, IPC_TOPIC, mChecker, mIPCServ, name, OSFILENAME, ParseCommandLine(), and safenew.

Referenced by InitTempDir().

1822 {
1823  wxString name = wxString::Format(wxT("audacity-lock-%s"), wxGetUserId());
1824  mChecker.reset();
1825  auto checker = std::make_unique<wxSingleInstanceChecker>();
1826 
1827 #if defined(__UNIX__)
1828  wxString sockFile(dir + wxT("/.audacity.sock"));
1829 #endif
1830 
1831  wxString runningTwoCopiesStr = _("Running two copies of Audacity simultaneously may cause\ndata loss or cause your system to crash.\n\n");
1832 
1833  if (!checker->Create(name, dir)) {
1834  // Error initializing the wxSingleInstanceChecker. We don't know
1835  // whether there is another instance running or not.
1836 
1837  wxString prompt =
1838  _("Audacity was not able to lock the temporary files directory.\nThis folder may be in use by another copy of Audacity.\n") +
1839  runningTwoCopiesStr +
1840  _("Do you still want to start Audacity?");
1841  int action = AudacityMessageBox(prompt,
1842  _("Error Locking Temporary Folder"),
1843  wxYES_NO | wxICON_EXCLAMATION,
1844  NULL);
1845  if (action == wxNO)
1846  return false;
1847  }
1848  else if ( checker->IsAnotherRunning() ) {
1849  // Parse the command line to ensure correct syntax, but
1850  // ignore options and only use the filenames, if any.
1851  auto parser = ParseCommandLine();
1852  if (!parser)
1853  {
1854  // Complaints have already been made
1855  return false;
1856  }
1857 
1858 #if defined(__WXMSW__)
1859  // On Windows, we attempt to make a connection
1860  // to an already active Audacity. If successful, we send
1861  // the first command line argument (the audio file name)
1862  // to that Audacity for processing.
1863  wxClient client;
1864 
1865  // We try up to 50 times since there's a small window
1866  // where the server may not have been fully initialized.
1867  for (int i = 0; i < 50; i++)
1868  {
1869  std::unique_ptr<wxConnectionBase> conn{ client.MakeConnection(wxEmptyString, IPC_APPL, IPC_TOPIC) };
1870  if (conn)
1871  {
1872  bool ok = false;
1873  if (parser->GetParamCount() > 0)
1874  {
1875  // Send each parameter to existing Audacity
1876  for (size_t i = 0, cnt = parser->GetParamCount(); i < cnt; i++)
1877  {
1878  ok = conn->Execute(parser->GetParam(i));
1879  }
1880  }
1881  else
1882  {
1883  // Send an empty string to force existing Audacity to front
1884  ok = conn->Execute(wxEmptyString);
1885  }
1886 
1887  if (ok)
1888  return false;
1889  }
1890 
1891  wxMilliSleep(10);
1892  }
1893 #else
1894  // On Unix-like machines, we use a local (file based) socket to
1895  // send the first command line argument to an already running
1896  // Audacity.
1897  wxUNIXaddress addr;
1898  addr.Filename(sockFile);
1899 
1900  {
1901  // Setup the socket
1902  // A wxSocketClient must not be deleted by us, but rather, let the
1903  // framework do appropriate delayed deletion after Destroy()
1904  Destroy_ptr<wxSocketClient> sock { safenew wxSocketClient() };
1905  sock->SetFlags(wxSOCKET_WAITALL);
1906 
1907  // We try up to 50 times since there's a small window
1908  // where the server may not have been fully initialized.
1909  for (int i = 0; i < 50; i++)
1910  {
1911  // Connect to the existing Audacity
1912  sock->Connect(addr, true);
1913  if (sock->IsConnected())
1914  {
1915  if (parser->GetParamCount() > 0)
1916  {
1917  for (size_t i = 0, cnt = parser->GetParamCount(); i < cnt; i++)
1918  {
1919  // Send the filename
1920  wxString param = parser->GetParam(i);
1921  sock->WriteMsg((const wxChar *) param, (param.Len() + 1) * sizeof(wxChar));
1922  }
1923  }
1924  else
1925  {
1926  // Send an empty string to force existing Audacity to front
1927  sock->WriteMsg(wxEmptyString, sizeof(wxChar));
1928  }
1929 
1930  return sock->Error();
1931  }
1932 
1933  wxMilliSleep(100);
1934  }
1935  }
1936 #endif
1937  // There is another copy of Audacity running. Force quit.
1938 
1939  wxString prompt =
1940  _("The system has detected that another copy of Audacity is running.\n") +
1941  runningTwoCopiesStr +
1942  _("Use the New or Open commands in the currently running Audacity\nprocess to open multiple projects simultaneously.\n");
1943  AudacityMessageBox(prompt, _("Audacity is already running"),
1944  wxOK | wxICON_ERROR);
1945  return false;
1946  }
1947 
1948 #if defined(__WXMSW__)
1949  // Create the DDE IPC server
1950  mIPCServ = std::make_unique<IPCServ>(IPC_APPL);
1951 #else
1952  int mask = umask(077);
1953  remove(OSFILENAME(sockFile));
1954  wxUNIXaddress addr;
1955  addr.Filename(sockFile);
1956  mIPCServ = std::make_unique<wxSocketServer>(addr, wxSOCKET_NOWAIT);
1957  umask(mask);
1958 
1959  if (!mIPCServ || !mIPCServ->IsOk())
1960  {
1961  // TODO: Complain here
1962  return false;
1963  }
1964 
1965  mIPCServ->SetEventHandler(*this, ID_IPC_SERVER);
1966  mIPCServ->SetNotify(wxSOCKET_CONNECTION_FLAG);
1967  mIPCServ->Notify(true);
1968 #endif
1969  mChecker = std::move(checker);
1970  return true;
1971 }
std::unique_ptr< wxSocketServer > mIPCServ
Definition: AudacityApp.h:206
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
#define OSFILENAME(X)
Definition: Internat.h:173
#define safenew
Definition: Audacity.h:230
#define IPC_APPL
#define IPC_TOPIC
#define ID_IPC_SERVER
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
const wxChar * name
Definition: Distortion.cpp:94
std::unique_ptr< wxCmdLineParser > ParseCommandLine()
std::unique_ptr< T, Destroyer< T >> Destroy_ptr
Definition: MemoryX.h:433
std::unique_ptr< wxSingleInstanceChecker > mChecker
Definition: AudacityApp.h:184
int AudacityApp::FilterEvent ( wxEvent &  event)
override

Definition at line 1170 of file AudacityApp.cpp.

1171 {
1172  (void)event;// compiler food (stops unused parameter warning)
1173 #if !wxCHECK_VERSION(3, 0, 0) && defined(__WXGTK__)
1174  // On wxGTK, there's a focus issue where dialogs do not automatically pass focus
1175  // to the first child. This means that you can use the keyboard to navigate within
1176  // the dialog. Watching for the ACTIVATE event allows us to set the focus ourselves
1177  // when each dialog opens.
1178  //
1179  // See bug #57
1180  //
1181  if (event.GetEventType() == wxEVT_ACTIVATE)
1182  {
1183  wxActivateEvent & e = (wxActivateEvent &) event;
1184 
1185  if (e.GetEventObject() && e.GetActive() && e.GetEventObject()->IsKindOf(CLASSINFO(wxDialog)))
1186  {
1187  ((wxWindow *)e.GetEventObject())->SetFocus();
1188  }
1189  }
1190 #endif
1191 
1192 
1193 #if defined(__WXMAC__) || defined(__WXGTK__)
1194  if (event.GetEventType() == wxEVT_ACTIVATE)
1195  {
1196  wxActivateEvent & e = static_cast<wxActivateEvent &>(event);
1197 
1198  const auto object = e.GetEventObject();
1199  if (object && e.GetActive() &&
1200  object->IsKindOf(CLASSINFO(wxWindow)))
1201  {
1202  const auto window = ((wxWindow *)e.GetEventObject());
1203  window->SetFocus();
1204 #if defined(__WXMAC__)
1205  window->NavigateIn();
1206 #endif
1207  }
1208  }
1209 #endif
1210 
1211  return Event_Skip;
1212 }
void AudacityApp::FindFilesInPathList ( const wxString &  pattern,
const wxArrayString &  pathList,
wxArrayString &  results,
int  flags = wxDIR_FILES 
)
static

Definition at line 2084 of file AudacityApp.cpp.

Referenced by ModuleManager::DiscoverProviders(), ModuleManager::Initialize(), and TranslationExists().

2088 {
2089  wxLogNull nolog;
2090 
2091  if (pattern == wxT("")) {
2092  return;
2093  }
2094 
2095  wxFileName ff;
2096 
2097  for(size_t i = 0; i < pathList.GetCount(); i++) {
2098  ff = pathList[i] + wxFILE_SEP_PATH + pattern;
2099  wxDir::GetAllFiles(ff.GetPath(), &results, ff.GetFullName(), flags);
2100  }
2101 }
AudacityLogger * AudacityApp::GetLogger ( )

Definition at line 966 of file AudacityApp.cpp.

Referenced by AudacityProject::OnShowLog().

967 {
968  // Use dynamic_cast so that we get a NULL ptr if we haven't yet
969  // setup our logger.
970  return dynamic_cast<AudacityLogger *>(wxLog::GetActiveTarget());
971 }
AudacityLogger is a thread-safe logger class.
FileHistory* AudacityApp::GetRecentFiles ( )
inline

Definition at line 154 of file AudacityApp.h.

References mRecentFiles.

Referenced by AudacityProject::CreateRecentFilesMenu(), AudacityProject::RebuildMenuBar(), and AudacityProject::~AudacityProject().

154 {return mRecentFiles.get();}
std::unique_ptr< FileHistory > mRecentFiles
Definition: AudacityApp.h:180
void AudacityApp::GetVersionKeysInit ( int &  major,
int &  minor,
int &  micro 
) const
inline

Definition at line 174 of file AudacityApp.h.

References mVersionMajorKeyInit, mVersionMicroKeyInit, and mVersionMinorKeyInit.

Referenced by ToolManager::ReadConfig().

int mVersionMajorKeyInit
Definition: AudacityApp.h:210
int mVersionMicroKeyInit
Definition: AudacityApp.h:212
int mVersionMinorKeyInit
Definition: AudacityApp.h:211
bool AudacityApp::GetWindowRectAlreadySaved ( ) const
inline

Definition at line 156 of file AudacityApp.h.

References mWindowRectAlreadySaved.

156 {return mWindowRectAlreadySaved;}
bool mWindowRectAlreadySaved
Definition: AudacityApp.h:201
void AudacityApp::InitCommandHandler ( )
private

Definition at line 1659 of file AudacityApp.cpp.

References mCmdHandler.

Referenced by OnInit().

1660 {
1661  mCmdHandler = std::make_unique<CommandHandler>();
1662  //SetNextHandler(mCmdHandler);
1663 }
std::unique_ptr< CommandHandler > mCmdHandler
Definition: AudacityApp.h:179
wxString AudacityApp::InitLang ( const wxString &  lang)

Definition at line 989 of file AudacityApp.cpp.

References _(), AudacityMessageBox(), audacityPathList, GetSystemLanguageCode(), Internat::Init(), IPC_APPL, and mLocale.

Referenced by GUIPrefs::Commit(), InitPreferences(), and NyquistEffect::Process().

990 {
991  wxString result = lang;
992 
993  mLocale.reset();
994 
995 #if defined(__WXMAC__)
996  // This should be reviewed again during the wx3 conversion.
997 
998  // On OSX, if the LANG environment variable isn't set when
999  // using a language like Japanese, an assertion will trigger
1000  // because conversion to Japanese from "?" doesn't return a
1001  // valid length, so make OSX happy by defining/overriding
1002  // the LANG environment variable with U.S. English for now.
1003  wxSetEnv(wxT("LANG"), wxT("en_US.UTF-8"));
1004 #endif
1005 
1006  const wxLanguageInfo *info = NULL;
1007  if (!lang.empty()) {
1008  info = wxLocale::FindLanguageInfo(lang);
1009  if (!info)
1010  ::AudacityMessageBox(wxString::Format(_("Language \"%s\" is unknown"), lang));
1011  }
1012  if (!info)
1013  {
1014  result = GetSystemLanguageCode();
1015  info = wxLocale::FindLanguageInfo(result);
1016  if (!info)
1017  return result;
1018  }
1019  mLocale = std::make_unique<wxLocale>(info->Language);
1020 
1021  for(unsigned int i=0; i<audacityPathList.GetCount(); i++)
1022  mLocale->AddCatalogLookupPathPrefix(audacityPathList[i]);
1023 
1024  // LL: Must add the wxWidgets catalog manually since the search
1025  // paths were not set up when mLocale was created. The
1026  // catalogs are search in LIFO order, so add wxstd first.
1027  mLocale->AddCatalog(wxT("wxstd"));
1028 
1029 // AUDACITY_NAME is legitimately used on some *nix configurations.
1030 #ifdef AUDACITY_NAME
1031  mLocale->AddCatalog(wxT(AUDACITY_NAME));
1032 #else
1033  mLocale->AddCatalog(IPC_APPL);
1034 #endif
1035 
1036  // Initialize internationalisation (number formats etc.)
1037  //
1038  // This must go _after_ creating the wxLocale instance because
1039  // creating the wxLocale instance sets the application-wide locale.
1040 
1041  Internat::Init();
1042 
1043  // Notify listeners of language changes
1044  {
1045  wxCommandEvent evt(EVT_LANGUAGE_CHANGE);
1046  ProcessEvent(evt);
1047  }
1048 
1049  // PRL: Moved this, do it only after language intialized
1050  // Unused strings that we want to be translated, even though
1051  // we're not using them yet...
1052  wxString future1 = _("Master Gain Control");
1053 
1054  return result;
1055 }
static void Init()
Initialize internationalisation support. Call this once at program start.
Definition: Internat.cpp:82
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
#define IPC_APPL
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxString GetSystemLanguageCode()
Definition: Languages.cpp:76
wxArrayString audacityPathList
A list of directories that should be searched for Audacity files (plug-ins, help files, etc.).
Definition: AudacityApp.h:138
std::unique_ptr< wxLocale > mLocale
Definition: AudacityApp.h:182
bool AudacityApp::InitTempDir ( )
private

Definition at line 1741 of file AudacityApp.cpp.

References _(), AudacityMessageBox(), CreateSingleInstanceChecker(), defaultTempDir, gPrefs, IsTempDirectoryNameOK(), OSFILENAME, DirManager::SetTempDir(), SetToExtantDirectory(), PrefsDialog::ShowModal(), and wxGetApp().

Referenced by OnInit().

1742 {
1743  // We need to find a temp directory location.
1744 
1745  wxString tempFromPrefs = gPrefs->Read(wxT("/Directories/TempDir"), wxT(""));
1746  wxString tempDefaultLoc = wxGetApp().defaultTempDir;
1747 
1748  wxString temp = wxT("");
1749 
1750  #ifdef __WXGTK__
1751  if (tempFromPrefs.Length() > 0 && tempFromPrefs[0] != wxT('/'))
1752  tempFromPrefs = wxT("");
1753  #endif
1754 
1755  // Stop wxWidgets from printing its own error messages
1756 
1757  wxLogNull logNo;
1758 
1759  // Try temp dir that was stored in prefs first
1760  if( IsTempDirectoryNameOK( tempFromPrefs ) )
1761  SetToExtantDirectory( temp, tempFromPrefs );
1762 
1763  // If that didn't work, try the default location
1764 
1765  if (temp==wxT(""))
1766  SetToExtantDirectory( temp, tempDefaultLoc );
1767 
1768  // Check temp directory ownership on *nix systems only
1769  #ifdef __UNIX__
1770  struct stat tempStatBuf;
1771  if ( lstat(temp.mb_str(), &tempStatBuf) != 0 ) {
1772  temp.clear();
1773  }
1774  else {
1775  if ( geteuid() != tempStatBuf.st_uid ) {
1776  temp.clear();
1777  }
1778  }
1779  #endif
1780 
1781  if (temp == wxT("")) {
1782  // Failed
1783  if( !IsTempDirectoryNameOK( tempFromPrefs ) ) {
1784  AudacityMessageBox(_("Audacity could not find a safe place to store temporary files.\nAudacity needs a place where automatic cleanup programs won't delete the temporary files.\nPlease enter an appropriate directory in the preferences dialog."));
1785  } else {
1786  AudacityMessageBox(_("Audacity could not find a place to store temporary files.\nPlease enter an appropriate directory in the preferences dialog."));
1787  }
1788 
1789  // Only want one page of the preferences
1790  DirectoriesPrefsFactory directoriesPrefsFactory;
1791  PrefsDialog::Factories factories;
1792  factories.push_back(&directoriesPrefsFactory);
1793  GlobalPrefsDialog dialog(NULL, factories);
1794  dialog.ShowModal();
1795 
1796  AudacityMessageBox(_("Audacity is now going to exit. Please launch Audacity again to use the new temporary directory."));
1797  return false;
1798  }
1799 
1800  // The permissions don't always seem to be set on
1801  // some platforms. Hopefully this fixes it...
1802  #ifdef __UNIX__
1803  chmod(OSFILENAME(temp), 0755);
1804  #endif
1805 
1806  bool bSuccess = gPrefs->Write(wxT("/Directories/TempDir"), temp) && gPrefs->Flush();
1807  DirManager::SetTempDir(temp);
1808 
1809  // Make sure the temp dir isn't locked by another process.
1810  if (!CreateSingleInstanceChecker(temp))
1811  return false;
1812 
1813  return bSuccess;
1814 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
#define OSFILENAME(X)
Definition: Internat.h:173
static bool IsTempDirectoryNameOK(const wxString &Name)
std::vector< PrefsNode > Factories
Definition: PrefsDialog.h:50
bool CreateSingleInstanceChecker(const wxString &dir)
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
AudacityApp & wxGetApp()
wxString defaultTempDir
Default temp directory.
Definition: AudacityApp.h:141
static void SetTempDir(const wxString &_temp)
Definition: DirManager.h:60
void SetToExtantDirectory(wxString &result, const wxString &dir)
bool AudacityApp::IsTempDirectoryNameOK ( const wxString &  Name)
static

Definition at line 1697 of file AudacityApp.cpp.

Referenced by InitTempDir(), DirectoriesPrefs::OnChooseTempDir(), and DirectoriesPrefs::Validate().

1697  {
1698  if( Name.IsEmpty() )
1699  return false;
1700 
1701  wxFileName tmpFile;
1702  tmpFile.AssignTempFileName(wxT("nn"));
1703  // use Long Path to expand out any abbreviated long substrings.
1704  wxString BadPath = tmpFile.GetLongPath();
1705  ::wxRemoveFile(tmpFile.GetFullPath());
1706 
1707 #ifdef __WXMAC__
1708  // This test is to fix bug 1220 on a 1.x to 2.x to 2.1.3 upgrade.
1709  // It is less permissive than we could be as it stops a path
1710  // with this string ANYWHERE within it rather than excluding just
1711  // the paths that the earlier Audacities used to create.
1712  if( Name.Contains( "/tmp/") )
1713  return false;
1714  BadPath = BadPath.BeforeLast( '/' ) + "/";
1715  wxFileName cmpFile( Name );
1716  wxString NameCanonical = cmpFile.GetLongPath( ) + "/";
1717 #else
1718  BadPath = BadPath.BeforeLast( '\\' ) + "\\";
1719  wxFileName cmpFile( Name );
1720  wxString NameCanonical = cmpFile.GetLongPath( ) + "\\";
1721 #endif
1722  return !(NameCanonical.StartsWith( BadPath ));
1723 }
void AudacityApp::MarkAliasedFilesMissingWarning ( const AliasBlockFile b)

Mark playback as having missing aliased blockfiles.

Playback will continue, but the missing files will be silenced ShouldShowMissingAliasedFileWarning can be called to determine if the user should be notified

Definition at line 924 of file AudacityApp.cpp.

References gAudacityProjects, AliasBlockFile::GetAliasedFileName(), m_LastMissingBlockFileLock, m_LastMissingBlockFilePath, and m_LastMissingBlockFileProject.

Referenced by BlockFile::CommonReadData(), and SetMissingAliasedFileWarningShouldShow().

925 {
927  if (b) {
928  size_t numProjects = gAudacityProjects.size();
929  for (size_t ii = 0; ii < numProjects; ++ii) {
930  // search each project for the blockfile
931  if (gAudacityProjects[ii]->GetDirManager()->ContainsBlockFile(b)) {
933  break;
934  }
935  }
936  }
937  else
939 
940  if (b)
941  m_LastMissingBlockFilePath = b->GetAliasedFileName().GetFullPath();
942  else
943  m_LastMissingBlockFilePath = wxString{};
944 }
std::weak_ptr< AudacityProject > m_LastMissingBlockFileProject
Definition: AudacityApp.h:189
AProjectArray gAudacityProjects
Definition: Project.cpp:303
ODLock m_LastMissingBlockFileLock
Definition: AudacityApp.h:192
const wxFileName & GetAliasedFileName() const
Definition: BlockFile.h:278
wxString m_LastMissingBlockFilePath
Definition: AudacityApp.h:190
bool AudacityApp::MRUOpen ( const wxString &  fileName)

Definition at line 765 of file AudacityApp.cpp.

References _(), AudacityMessageBox(), GetActiveProject(), AudacityProject::GetDirty(), AudacityProject::GetIsEmpty(), AudacityProject::IsAlreadyOpen(), FileNames::Open, AudacityProject::OpenProject(), and FileNames::UpdateDefaultPath().

Referenced by OnMRUFile(), and SafeMRUOpen().

765  {
766  // Most of the checks below are copied from AudacityProject::OpenFiles.
767  // - some rationalisation might be possible.
768 
770 
771  if (!fullPathStr.IsEmpty())
772  {
773  // verify that the file exists
774  if (wxFile::Exists(fullPathStr))
775  {
777 
778  // Make sure it isn't already open.
779  // Test here even though AudacityProject::OpenFile() also now checks, because
780  // that method does not return the bad result.
781  // That itself may be a FIXME.
782  if (AudacityProject::IsAlreadyOpen(fullPathStr))
783  return false;
784 
785  // DMM: If the project is dirty, that means it's been touched at
786  // all, and it's not safe to open a NEW project directly in its
787  // place. Only if the project is brand-NEW clean and the user
788  // hasn't done any action at all is it safe for Open to take place
789  // inside the current project.
790  //
791  // If you try to Open a NEW project inside the current window when
792  // there are no tracks, but there's an Undo history, etc, then
793  // bad things can happen, including data files moving to the NEW
794  // project directory, etc.
795  if (proj && (proj->GetDirty() || !proj->GetIsEmpty()))
796  proj = nullptr;
797  // This project is clean; it's never been touched. Therefore
798  // all relevant member variables are in their initial state,
799  // and it's okay to open a NEW project inside this window.
800  AudacityProject::OpenProject( proj, fullPathStr );
801  }
802  else {
803  // File doesn't exist - remove file from history
804  AudacityMessageBox(wxString::Format(_("%s could not be found.\n\nIt has been removed from the list of recent files."),
805  fullPathStr));
806  return(false);
807  }
808  }
809  return(true);
810 }
bool GetDirty()
Definition: Project.h:303
static bool IsAlreadyOpen(const wxString &projPathName)
Definition: Project.cpp:2867
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
static void UpdateDefaultPath(Operation op, const wxString &path)
Definition: FileNames.cpp:399
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
bool GetIsEmpty()
Definition: Project.cpp:1507
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
static AudacityProject * OpenProject(AudacityProject *pProject, const wxString &fileNameArg, bool addtohistory=true)
Definition: Project.cpp:2967
void AudacityApp::OnEndSession ( wxCloseEvent &  event)

Definition at line 2117 of file AudacityApp.cpp.

References gAudacityProjects, and gIsQuitting.

Referenced by OnQueryEndSession().

2118 {
2119  bool force = !event.CanVeto();
2120 
2121  // Try to close each open window. If the user hits Cancel
2122  // in a Save Changes dialog, don't continue.
2123  if (!gAudacityProjects.empty()) {
2124  while (gAudacityProjects.size()) {
2125  // Closing the project has side-effect of
2126  // deletion from gAudacityProjects
2127  if (force) {
2128  gAudacityProjects[0]->Close(true);
2129  }
2130  else if (!gAudacityProjects[0]->Close()) {
2131  gIsQuitting = false;
2132  event.Veto();
2133  break;
2134  }
2135  }
2136  }
2137 }
AProjectArray gAudacityProjects
Definition: Project.cpp:303
bool gIsQuitting
bool AudacityApp::OnExceptionInMainLoop ( )
override

Definition at line 1073 of file AudacityApp.cpp.

References AudacityException::DelayedHandlerAction(), and GetActiveProject().

1074 {
1075  // This function is invoked from catch blocks in the wxWidgets framework,
1076  // and throw; without argument re-throws the exception being handled,
1077  // letting us dispatch according to its type.
1078 
1079  try { throw; }
1080  catch ( AudacityException &e ) {
1081  // Here is the catch-all for our own exceptions
1082 
1083  // Use CallAfter to delay this to the next pass of the event loop,
1084  // rather than risk doing it inside stack unwinding.
1085  auto pProject = ::GetActiveProject();
1086  auto pException = std::current_exception();
1087  CallAfter( [=] // Capture pException by value!
1088  {
1089 
1090  // Restore the state of the project to what it was before the
1091  // failed operation
1092  pProject->RollbackState();
1093 
1094  // Forget pending changes in the TrackList
1095  pProject->GetTracks()->ClearPendingTracks();
1096 
1097  pProject->RedrawProject();
1098 
1099  // Give the user an alert
1100  try { std::rethrow_exception( pException ); }
1101  catch( AudacityException &e )
1102  { e.DelayedHandlerAction(); }
1103 
1104  } );
1105 
1106  // Don't quit the program
1107  return true;
1108  }
1109  catch ( ... ) {
1110  // There was some other type of exception we don't know.
1111  // Let the inherited function do throw; again and whatever else it does.
1112  return wxApp::OnExceptionInMainLoop();
1113  }
1114  // Shouldn't ever reach this line
1115  return false;
1116 }
root of a hierarchy of classes that are thrown and caught by Audacity.
virtual void DelayedHandlerAction()=0
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
int AudacityApp::OnExit ( void  )
override

Definition at line 2144 of file AudacityApp.cpp.

References DeinitAudioIO(), DeinitFFT(), FinishPreferences(), Importer::Get(), PluginManager::Get(), gIsQuitting, gPrefs, mIPCServ, mRecentFiles, OSFILENAME, Importer::Terminate(), and PluginManager::Terminate().

2145 {
2146  gIsQuitting = true;
2147  while(Pending())
2148  {
2149  Dispatch();
2150  }
2151 
2153 
2154  if(gPrefs)
2155  {
2156  bool bFalse = false;
2157  //Should we change the commands.cfg location next startup?
2158  if(gPrefs->Read(wxT("/QDeleteCmdCfgLocation"), &bFalse))
2159  {
2160  gPrefs->DeleteEntry(wxT("/QDeleteCmdCfgLocation"));
2161  gPrefs->Write(wxT("/DeleteCmdCfgLocation"), true);
2162  gPrefs->Flush();
2163  }
2164  }
2165 
2166  mRecentFiles->Save(*gPrefs, wxT("RecentFiles"));
2167 
2169 
2170 #ifdef USE_FFMPEG
2171  DropFFmpegLibs();
2172 #endif
2173 
2174  DeinitFFT();
2175 
2176  DeinitAudioIO();
2177 
2178  // Terminate the PluginManager (must be done before deleting the locale)
2180 
2181  if (mIPCServ)
2182  {
2183 #if defined(__UNIX__)
2184  wxUNIXaddress addr;
2185  if (mIPCServ->GetLocal(addr))
2186  {
2187  remove(OSFILENAME(addr.Filename()));
2188  }
2189 #endif
2190  }
2191 
2192  return 0;
2193 }
void FinishPreferences()
Definition: Prefs.cpp:369
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
std::unique_ptr< wxSocketServer > mIPCServ
Definition: AudacityApp.h:206
#define OSFILENAME(X)
Definition: Internat.h:173
void DeinitAudioIO()
Definition: AudioIO.cpp:1149
std::unique_ptr< FileHistory > mRecentFiles
Definition: AudacityApp.h:180
static PluginManager & Get()
static Importer & Get()
Definition: Import.cpp:71
bool gIsQuitting
bool Terminate()
Definition: Import.cpp:114
void DeinitFFT()
Definition: FFT.cpp:115
void AudacityApp::OnFatalException ( )
override

Definition at line 1057 of file AudacityApp.cpp.

1058 {
1059 #if defined(EXPERIMENTAL_CRASH_REPORT)
1060  GenerateCrashReport(wxDebugReport::Context_Exception);
1061 #endif
1062 
1063  exit(-1);
1064 }
bool AudacityApp::OnInit ( void  )
override

Definition at line 1232 of file AudacityApp.cpp.

References _(), AddMultiPathsToPathList(), AddUniquePathToPathList(), AppInitialized, AUDACITY_VERSION_STRING, audacityPathList, CreateNewAudacityProject(), AutoSaveFile::Decode(), defaultTempDir, ModuleManager::Dispatch(), Theme::EnsureInitialised(), FinishPreferences(), ModuleManager::Get(), Importer::Get(), PluginManager::Get(), GetNextWindowPlacement(), gInited, gPrefs, ID_RECENT_CLEAR, ID_RECENT_FIRST, ID_RECENT_LAST, AColor::Init(), InitAudioIO(), InitCommandHandler(), InitDitherers(), ModuleManager::Initialize(), Importer::Initialize(), PluginManager::Initialize(), InitPreferences(), InitTempDir(), m_aliasMissingWarningShouldShow, MakeHijackPanel(), AudacityProject::MayStartMonitoring(), mCmdHandler, FileNames::MkDir(), mLocale, mRecentFiles, AudacityProject::mShowSplashScreen, mTimer, mWindowRectAlreadySaved, AudacityProject::OnHelpWelcome(), ParseCommandLine(), QuitAudacity(), RunBenchmark(), SafeMRUOpen(), safenew, DirManager::SetDontDeleteTempFiles(), Sequence::SetMaxDiskBlockSize(), ShowAutoRecoveryDialogIfNeeded(), and theTheme.

1233 {
1234  // JKC: ANSWER-ME: Who actually added the event loop guarantor?
1235  // Although 'blame' says Leland, I think it came from a donated patch.
1236 
1237  // PRL: It was added by LL at 54676a72285ba7ee3a69920e91fa390a71ef10c9 :
1238  // " Ensure OnInit() has an event loop
1239  // And allow events to flow so the splash window updates under GTK"
1240  // then mistakenly lost in the merge at
1241  // 37168ebbf67ae869ab71a3b5cbbf1d2a48e824aa
1242  // then restored at 7687972aa4b2199f0717165235f3ef68ade71e08
1243 
1244  // Ensure we have an event loop during initialization
1245  wxEventLoopGuarantor eventLoop;
1246 
1247  // wxWidgets will clean up the logger for the main thread, so we can say
1248  // safenew. See:
1249  // http://docs.wxwidgets.org/3.0/classwx_log.html#a2525bf54fa3f31dc50e6e3cd8651e71d
1250  std::unique_ptr < wxLog >
1251  { wxLog::SetActiveTarget(safenew AudacityLogger) }; // DELETE old
1252 
1253  mLocale = NULL;
1254 
1256 
1257 #if defined(__WXMAC__)
1258  // Disable window animation
1259  wxSystemOptions::SetOption(wxMAC_WINDOW_PLAIN_TRANSITION, 1);
1260 #endif
1261 
1262  // Don't use AUDACITY_NAME here.
1263  // We want Audacity with a capital 'A'
1264 
1265 // DA: App name
1266 #ifndef EXPERIMENTAL_DA
1267  wxString appName = wxT("Audacity");
1268 #else
1269  wxString appName = wxT("DarkAudacity");
1270 #endif
1271 
1272  wxTheApp->SetAppName(appName);
1273  // Explicitly set since OSX will use it for the "Quit" menu item
1274  wxTheApp->SetAppDisplayName(appName);
1275  wxTheApp->SetVendorName(appName);
1276 
1277  ::wxInitAllImageHandlers();
1278 
1279  // AddHandler takes ownership
1280  wxFileSystem::AddHandler(safenew wxZipFSHandler);
1281 
1282  //
1283  // Paths: set search path and temp dir path
1284  //
1285 
1286 #ifdef __WXGTK__
1287  /* Search path (for plug-ins, translations etc) is (in this order):
1288  * The AUDACITY_PATH environment variable
1289  * The current directory
1290  * The user's .audacity-files directory in their home directory
1291  * The "share" and "share/doc" directories in their install path */
1292  wxString home = wxGetHomeDir();
1293 
1294  wxString envTempDir = wxGetenv(wxT("TMPDIR"));
1295  if (envTempDir != wxT("")) {
1296  /* On Unix systems, the environment variable TMPDIR may point to
1297  an unusual path when /tmp and /var/tmp are not desirable. */
1298  defaultTempDir.Printf(wxT("%s/audacity-%s"), envTempDir, wxGetUserId());
1299  } else {
1300  /* On Unix systems, the default temp dir is in /var/tmp. */
1301  defaultTempDir.Printf(wxT("/var/tmp/audacity-%s"), wxGetUserId());
1302  }
1303 
1304 // DA: Path env variable.
1305 #ifndef EXPERIMENTAL_DA
1306  wxString pathVar = wxGetenv(wxT("AUDACITY_PATH"));
1307 #else
1308  wxString pathVar = wxGetenv(wxT("DARKAUDACITY_PATH"));
1309 #endif
1310  if (pathVar != wxT(""))
1313 
1314 #ifdef AUDACITY_NAME
1315  AddUniquePathToPathList(wxString::Format(wxT("%s/.%s-files"),
1316  home, wxT(AUDACITY_NAME)),
1318  AddUniquePathToPathList(wxString::Format(wxT("%s/share/%s"),
1319  wxT(INSTALL_PREFIX), wxT(AUDACITY_NAME)),
1321  AddUniquePathToPathList(wxString::Format(wxT("%s/share/doc/%s"),
1322  wxT(INSTALL_PREFIX), wxT(AUDACITY_NAME)),
1324 #else //AUDACITY_NAME
1325  AddUniquePathToPathList(wxString::Format(wxT("%s/.audacity-files"),
1326  home),
1328  AddUniquePathToPathList(wxString::Format(wxT("%s/share/audacity"),
1329  wxT(INSTALL_PREFIX)),
1331  AddUniquePathToPathList(wxString::Format(wxT("%s/share/doc/audacity"),
1332  wxT(INSTALL_PREFIX)),
1334 #endif //AUDACITY_NAME
1335 
1336  AddUniquePathToPathList(wxString::Format(wxT("%s/share/locale"),
1337  wxT(INSTALL_PREFIX)),
1339 
1340  AddUniquePathToPathList(wxString::Format(wxT("./locale")),
1342 
1343 #endif //__WXGTK__
1344 
1345 // JKC Bug 1220: Use path based on home directory on WXMAC
1346 #ifdef __WXMAC__
1347  wxFileName tmpFile;
1348  tmpFile.AssignHomeDir();
1349  wxString tmpDirLoc = tmpFile.GetPath(wxPATH_GET_VOLUME);
1350 #else
1351  wxFileName tmpFile;
1352  tmpFile.AssignTempFileName(wxT("nn"));
1353  wxString tmpDirLoc = tmpFile.GetPath(wxPATH_GET_VOLUME);
1354  ::wxRemoveFile(tmpFile.GetFullPath());
1355 #endif
1356 
1357 
1358 
1359  // On Mac and Windows systems, use the directory which contains Audacity.
1360 #ifdef __WXMSW__
1361  // On Windows, the path to the Audacity program is in argv[0]
1362  wxString progPath = wxPathOnly(argv[0]);
1364  AddUniquePathToPathList(progPath + wxT("\\Languages"), audacityPathList);
1365 
1366  // See bug #1271 for explanation of location
1367  tmpDirLoc = FileNames::MkDir(wxStandardPaths::Get().GetUserLocalDataDir());
1368  defaultTempDir.Printf(wxT("%s\\SessionData"),
1369  tmpDirLoc);
1370 #endif //__WXWSW__
1371 
1372 #ifdef __WXMAC__
1373  // On Mac OS X, the path to the Audacity program is in argv[0]
1374  wxString progPath = wxPathOnly(argv[0]);
1375 
1377  // If Audacity is a "bundle" package, then the root directory is
1378  // the great-great-grandparent of the directory containing the executable.
1379  //AddUniquePathToPathList(progPath + wxT("/../../../"), audacityPathList);
1380 
1381  // These allow for searching the "bundle"
1382  AddUniquePathToPathList(progPath + wxT("/../"), audacityPathList);
1383  AddUniquePathToPathList(progPath + wxT("/../Resources"), audacityPathList);
1384 
1385  // JKC Bug 1220: Using an actual temp directory for session data on Mac was
1386  // wrong because it would get cleared out on a reboot.
1387  defaultTempDir.Printf(wxT("%s/Library/Application Support/audacity/SessionData"),
1388  tmpDirLoc);
1389 
1390  //defaultTempDir.Printf(wxT("%s/audacity-%s"),
1391  // tmpDirLoc,
1392  // wxGetUserId());
1393 #endif //__WXMAC__
1394 
1395  // Define languanges for which we have translations, but that are not yet
1396  // supported by wxWidgets.
1397  //
1398  // TODO: The whole Language initialization really need to be reworked.
1399  // It's all over the place.
1400 #if wxCHECK_VERSION(3, 0, 1)
1401  for (size_t i = 0, cnt = WXSIZEOF(userLangs); i < cnt; i++)
1402  {
1403  wxLocale::AddLanguage(userLangs[i]);
1404  }
1405 #endif
1406 
1407  // Initialize preferences and language
1408  InitPreferences();
1409 
1410 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__CYGWIN__)
1411  this->AssociateFileTypes();
1412 #endif
1413 
1414  // TODO - read the number of files to store in history from preferences
1415  mRecentFiles = std::make_unique<FileHistory>(ID_RECENT_LAST - ID_RECENT_FIRST + 1, ID_RECENT_CLEAR);
1416  mRecentFiles->Load(*gPrefs, wxT("RecentFiles"));
1417 
1419 
1420  // AColor depends on theTheme.
1421  AColor::Init();
1422 
1423  // Init DirManager, which initializes the temp directory
1424  // If this fails, we must exit the program.
1425  if (!InitTempDir()) {
1427  return false;
1428  }
1429 
1430  //<<<< Try to avoid dialogs before this point.
1431  // The reason is that InitTempDir starts the single instance checker.
1432  // If we're waiitng in a dialog before then we can very easily
1433  // start multiple instances, defeating the single instance checker.
1434 
1435  // Initialize the CommandHandler
1437 
1438  // Initialize the PluginManager
1440 
1441  // Initialize the ModuleManager, including loading found modules
1443 
1444  // Parse command line and handle options that might require
1445  // immediate exit...no need to initialize all of the audio
1446  // stuff to display the version string.
1447  std::shared_ptr< wxCmdLineParser > parser{ ParseCommandLine().release() };
1448  if (!parser)
1449  {
1450  // Either user requested help or a parsing error occured
1451  exit(1);
1452  }
1453 
1454  if (parser->Found(wxT("v")))
1455  {
1456  wxFprintf(stderr, wxT("Audacity v%s\n"), AUDACITY_VERSION_STRING);
1457  exit(0);
1458  }
1459 
1460  long lval;
1461  if (parser->Found(wxT("b"), &lval))
1462  {
1463  if (lval < 256 || lval > 100000000)
1464  {
1465  wxPrintf(_("Block size must be within 256 to 100000000\n"));
1466  exit(1);
1467  }
1468 
1470  }
1471 
1472  wxString fileName;
1473  if (parser->Found(wxT("d"), &fileName))
1474  {
1475  AutoSaveFile asf;
1476  if (asf.Decode(fileName))
1477  {
1478  wxPrintf(_("File decoded successfully\n"));
1479  }
1480  else
1481  {
1482  wxPrintf(_("Decoding failed\n"));
1483  }
1484  exit(1);
1485  }
1486 
1487  // BG: Create a temporary window to set as the top window
1488  wxImage logoimage((const char **)AudacityLogoWithName_xpm);
1489  logoimage.Rescale(logoimage.GetWidth() / 2, logoimage.GetHeight() / 2);
1490  wxBitmap logo(logoimage);
1491 
1492  AudacityProject *project;
1493  {
1494  // Bug 718: Position splash screen on same screen
1495  // as where Audacity project will appear.
1496  wxRect wndRect;
1497  bool bMaximized = false;
1498  bool bIconized = false;
1499  GetNextWindowPlacement(&wndRect, &bMaximized, &bIconized);
1500 
1501  wxSplashScreen temporarywindow(
1502  logo,
1503  wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT,
1504  0,
1505  NULL,
1506  wxID_ANY,
1507  wndRect.GetTopLeft(),
1508  wxDefaultSize,
1509  wxSTAY_ON_TOP);
1510 
1511  // Unfortunately with the Windows 10 Creators update, the splash screen
1512  // now appears before setting its position.
1513  // On a dual monitor screen it will appear on one screen and then
1514  // possibly jump to the second.
1515  // We could fix this by writing outr own splash screen and using Hide()
1516  // until the splash scren was correctly positioned, then Show()
1517 
1518  // Possibly move it on to the second screen...
1519  temporarywindow.SetPosition( wndRect.GetTopLeft() );
1520  // Centered on whichever screen it is on.
1521  temporarywindow.Center();
1522  temporarywindow.SetTitle(_("Audacity is starting up..."));
1523  SetTopWindow(&temporarywindow);
1524 
1525  // ANSWER-ME: Why is YieldFor needed at all?
1526  //wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT|wxEVT_CATEGORY_UNKNOWN);
1527  wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
1528 
1529  //JKC: Would like to put module loading here.
1530 
1531  // More initialization
1532 
1533  InitDitherers();
1534  InitAudioIO();
1535 
1536 #ifdef __WXMAC__
1537 
1538  // On the Mac, users don't expect a program to quit when you close the last window.
1539  // Create a menubar that will show when all project windows are closed.
1540 
1541  auto fileMenu = std::make_unique<wxMenu>();
1542  auto urecentMenu = std::make_unique<wxMenu>();
1543  auto recentMenu = urecentMenu.get();
1544  fileMenu->Append(wxID_NEW, wxString(_("&New")) + wxT("\tCtrl+N"));
1545  fileMenu->Append(wxID_OPEN, wxString(_("&Open...")) + wxT("\tCtrl+O"));
1546  fileMenu->AppendSubMenu(urecentMenu.release(), _("Open &Recent..."));
1547  fileMenu->Append(wxID_ABOUT, _("&About Audacity..."));
1548  fileMenu->Append(wxID_PREFERENCES, wxString(_("&Preferences...")) + wxT("\tCtrl+,"));
1549 
1550  {
1551  auto menuBar = std::make_unique<wxMenuBar>();
1552  menuBar->Append(fileMenu.release(), _("&File"));
1553 
1554  // PRL: Are we sure wxWindows will not leak this menuBar?
1555  // The online documentation is not explicit.
1556  wxMenuBar::MacSetCommonMenuBar(menuBar.release());
1557  }
1558 
1559  mRecentFiles->UseMenu(recentMenu);
1560  mRecentFiles->AddFilesToMenu(recentMenu);
1561 
1562  SetExitOnFrameDelete(false);
1563 
1564 #endif //__WXMAC__
1565  temporarywindow.Show(false);
1566  }
1567 
1568  // Workaround Bug 1377 - Crash after Audacity starts and low disk space warning appears
1569  // The temporary splash window is closed AND cleaned up, before attempting to create
1570  // a project and possibly creating a modal warning dialog by doing so.
1571  // Also fixes problem of warning being obscured.
1572  // Downside is that we have no splash screen for the (brief) time that we spend
1573  // creating the project.
1574  // Root cause is problem with wxSplashScreen and other dialogs co-existing, that
1575  // seemed to arrive with wx3.
1576  {
1577  project = CreateNewAudacityProject();
1578  mCmdHandler->SetProject(project);
1579  wxWindow * pWnd = MakeHijackPanel();
1580  if (pWnd)
1581  {
1582  project->Show(false);
1583  pWnd->SetParent(project);
1584  SetTopWindow(pWnd);
1585  pWnd->Show(true);
1586  }
1587  }
1588 
1589  if( project->mShowSplashScreen ){
1590  // This may do a check-for-updates at every start up.
1591  // Mainly this is to tell users of ALPHAS who don't know that they have an ALPHA.
1592  // Disabled for now, after discussion.
1593  // project->MayCheckForUpdates();
1594  project->OnHelpWelcome(*project);
1595  }
1596 
1597  // JKC 10-Sep-2007: Enable monitoring from the start.
1598  // (recommended by lprod.org).
1599  // Monitoring stops again after any
1600  // PLAY or RECORD completes.
1601  // So we also call StartMonitoring when STOP is called.
1602  project->MayStartMonitoring();
1603 
1604  #ifdef USE_FFMPEG
1605  FFmpegStartup();
1606  #endif
1607 
1609 
1610  // Bug1561: delay the recovery dialog, to avoid crashes.
1611  CallAfter( [=] () mutable {
1612  //
1613  // Auto-recovery
1614  //
1615  bool didRecoverAnything = false;
1616  if (!ShowAutoRecoveryDialogIfNeeded(&project, &didRecoverAnything))
1617  {
1618  // Important: Prevent deleting any temporary files!
1620  QuitAudacity(true);
1621  }
1622 
1623  //
1624  // Remainder of command line parsing, but only if we didn't recover
1625  //
1626  if (!didRecoverAnything)
1627  {
1628  if (parser->Found(wxT("t")))
1629  {
1630  RunBenchmark(NULL);
1631  QuitAudacity(true);
1632  }
1633 
1634  // As of wx3, there's no need to process the filename arguments as they
1635  // will be sent view the MacOpenFile() method.
1636 #if !defined(__WXMAC__)
1637  for (size_t i = 0, cnt = parser->GetParamCount(); i < cnt; i++)
1638  {
1639  // PRL: Catch any exceptions, don't try this file again, continue to
1640  // other files.
1641  SafeMRUOpen(parser->GetParam(i));
1642  }
1643 #endif
1644  }
1645  } );
1646 
1647  gInited = true;
1648 
1650 
1651  mWindowRectAlreadySaved = FALSE;
1652 
1653  mTimer.SetOwner(this, kAudacityAppTimerID);
1654  mTimer.Start(200);
1655 
1656  return TRUE;
1657 }
void FinishPreferences()
Definition: Prefs.cpp:369
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
#define AUDACITY_VERSION_STRING
Definition: Audacity.h:81
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
wxTimer mTimer
Definition: AudacityApp.h:186
void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized)
Definition: Project.cpp:718
bool mWindowRectAlreadySaved
Definition: AudacityApp.h:201
static ModuleManager & Get()
bool m_aliasMissingWarningShouldShow
Definition: AudacityApp.h:188
void RunBenchmark(wxWindow *parent)
Definition: Benchmark.cpp:82
bool mShowSplashScreen
Definition: Project.h:705
bool Initialize()
Definition: Import.cpp:84
void MayStartMonitoring()
Definition: Project.cpp:5534
#define ID_RECENT_FIRST
void InitCommandHandler()
void EnsureInitialised() override
Definition: Theme.cpp:221
static void AddMultiPathsToPathList(const wxString &multiPathString, wxArrayString &pathList)
std::unique_ptr< CommandHandler > mCmdHandler
Definition: AudacityApp.h:179
AudacityLogger is a thread-safe logger class.
#define safenew
Definition: Audacity.h:230
int Dispatch(ModuleDispatchTypes type)
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
void InitDitherers()
static void SetMaxDiskBlockSize(size_t bytes)
Definition: Sequence.cpp:2011
#define kAudacityAppTimerID
bool SafeMRUOpen(const wxString &fileName)
static void Init()
Definition: AColor.cpp:460
void QuitAudacity(bool bForce)
void InitPreferences()
Definition: Prefs.cpp:169
static bool gInited
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
static void AddUniquePathToPathList(const wxString &path, wxArrayString &pathList)
bool InitTempDir()
bool Decode(const wxString &fileName)
void Initialize(CommandHandler &cmdHandler)
wxArrayString audacityPathList
A list of directories that should be searched for Audacity files (plug-ins, help files, etc.).
Definition: AudacityApp.h:138
#define ID_RECENT_LAST
std::unique_ptr< wxLocale > mLocale
Definition: AudacityApp.h:182
std::unique_ptr< wxCmdLineParser > ParseCommandLine()
static wxString MkDir(const wxString &Str)
Definition: FileNames.cpp:72
std::unique_ptr< FileHistory > mRecentFiles
Definition: AudacityApp.h:180
void InitAudioIO()
Definition: AudioIO.cpp:1116
wxWindow * MakeHijackPanel()
#define ID_RECENT_CLEAR
void OnHelpWelcome(const CommandContext &context)
Definition: Menus.cpp:8827
wxString defaultTempDir
Default temp directory.
Definition: AudacityApp.h:141
static PluginManager & Get()
static Importer & Get()
Definition: Import.cpp:71
bool ShowAutoRecoveryDialogIfNeeded(AudacityProject **pproj, bool *didRecoverAnything)
static void SetDontDeleteTempFiles()
Definition: DirManager.h:176
a class wrapping reading and writing of arbitrary data in text or binary format to a file...
Definition: AutoRecovery.h:76
AudacityProject * CreateNewAudacityProject()
Definition: Project.cpp:549
void AudacityApp::OnKeyDown ( wxKeyEvent &  event)

Definition at line 1672 of file AudacityApp.cpp.

References gAudioIO, GetActiveProject(), AudioIO::GetNumCaptureChannels(), and AudioIO::IsAudioTokenActive().

1673 {
1674  if(event.GetKeyCode() == WXK_ESCAPE) {
1675  // Stop play, including scrub, but not record
1676  auto project = ::GetActiveProject();
1677  auto token = project->GetAudioIOToken();
1678  auto &scrubber = project->GetScrubber();
1679  auto scrubbing = scrubber.HasStartedScrubbing();
1680  if (scrubbing)
1681  scrubber.Cancel();
1682  if((token > 0 &&
1683  gAudioIO->IsAudioTokenActive(token) &&
1684  gAudioIO->GetNumCaptureChannels() == 0) ||
1685  scrubbing)
1686  // ESC out of other play (but not record)
1687  project->OnStop(*project);
1688  else
1689  event.Skip();
1690  }
1691  else
1692  event.Skip();
1693 }
unsigned GetNumCaptureChannels() const
Definition: AudioIO.h:399
bool IsAudioTokenActive(int token)
Returns true if the stream is active, or even if audio I/O is busy cleaning up its data or writing to...
Definition: AudioIO.cpp:2909
AudioIO * gAudioIO
Definition: AudioIO.cpp:482
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
void AudacityApp::OnMenuAbout ( wxCommandEvent &  event)

Definition at line 2205 of file AudacityApp.cpp.

References AboutDialog::ActiveIntance(), and safenew.

Referenced by AudacityProject::OnAbout().

2206 {
2207  // This function shadows a similar function
2208  // in Menus.cpp, but should only be used on the Mac platform.
2209 #ifdef __WXMAC__
2210  // Modeless dialog, consistent with other Mac applications
2211  // Not more than one at once!
2212  const auto instance = AboutDialog::ActiveIntance();
2213  if (instance)
2214  instance->Raise();
2215  else
2216  // This dialog deletes itself when dismissed
2217  (safenew AboutDialog{ nullptr })->Show(true);
2218 #else
2219  wxASSERT(false);
2220 #endif
2221 }
static AboutDialog * ActiveIntance()
#define safenew
Definition: Audacity.h:230
The AboutDialog shows the program version and developer credits.
Definition: AboutDialog.h:51
void AudacityApp::OnMenuExit ( wxCommandEvent &  event)

Definition at line 2272 of file AudacityApp.cpp.

References gAudacityProjects, and QuitAudacity().

2273 {
2274  // This function shadows a similar function
2275  // in Menus.cpp, but should only be used on the Mac platform
2276  // when no project windows are open. This check assures that
2277  // this happens, and enable the same code to be present on
2278  // all platforms.
2279 
2280  // LL: Removed "if" to allow closing based on final project count.
2281  // if(gAudacityProjects.size() == 0)
2282  QuitAudacity();
2283 
2284  // LL: Veto quit if projects are still open. This can happen
2285  // if the user selected Cancel in a Save dialog.
2286  event.Skip(gAudacityProjects.size() == 0);
2287 
2288 }
AProjectArray gAudacityProjects
Definition: Project.cpp:303
void QuitAudacity(bool bForce)
void AudacityApp::OnMenuNew ( wxCommandEvent &  event)

Definition at line 2223 of file AudacityApp.cpp.

References CreateNewAudacityProject(), and gAudacityProjects.

2224 {
2225  // This function shadows a similar function
2226  // in Menus.cpp, but should only be used on the Mac platform
2227  // when no project windows are open. This check assures that
2228  // this happens, and enable the same code to be present on
2229  // all platforms.
2230 
2231  if(gAudacityProjects.size() == 0)
2233  else
2234  event.Skip();
2235 }
AProjectArray gAudacityProjects
Definition: Project.cpp:303
AudacityProject * CreateNewAudacityProject()
Definition: Project.cpp:549
void AudacityApp::OnMenuOpen ( wxCommandEvent &  event)

Definition at line 2238 of file AudacityApp.cpp.

References gAudacityProjects, and AudacityProject::OpenFiles().

2239 {
2240  // This function shadows a similar function
2241  // in Menus.cpp, but should only be used on the Mac platform
2242  // when no project windows are open. This check assures that
2243  // this happens, and enable the same code to be present on
2244  // all platforms.
2245 
2246 
2247  if(gAudacityProjects.size() == 0)
2249  else
2250  event.Skip();
2251 
2252 
2253 }
AProjectArray gAudacityProjects
Definition: Project.cpp:303
static void OpenFiles(AudacityProject *proj)
Definition: Project.cpp:2887
void AudacityApp::OnMenuPreferences ( wxCommandEvent &  event)

Definition at line 2255 of file AudacityApp.cpp.

References gAudacityProjects, and PrefsDialog::ShowModal().

2256 {
2257  // This function shadows a similar function
2258  // in Menus.cpp, but should only be used on the Mac platform
2259  // when no project windows are open. This check assures that
2260  // this happens, and enable the same code to be present on
2261  // all platforms.
2262 
2263  if(gAudacityProjects.size() == 0) {
2264  GlobalPrefsDialog dialog(NULL /* parent */ );
2265  dialog.ShowModal();
2266  }
2267  else
2268  event.Skip();
2269 
2270 }
AProjectArray gAudacityProjects
Definition: Project.cpp:303
void AudacityApp::OnMRUClear ( wxCommandEvent &  event)

Definition at line 817 of file AudacityApp.cpp.

References mRecentFiles.

818 {
819  mRecentFiles->Clear();
820 }
std::unique_ptr< FileHistory > mRecentFiles
Definition: AudacityApp.h:180
void AudacityApp::OnMRUFile ( wxCommandEvent &  event)

Definition at line 825 of file AudacityApp.cpp.

References ID_RECENT_FIRST, AudacityProject::IsAlreadyOpen(), mRecentFiles, and MRUOpen().

825  {
826  int n = event.GetId() - ID_RECENT_FIRST;
827  const wxString &fullPathStr = mRecentFiles->GetHistoryFile(n);
828 
829  // Try to open only if not already open.
830  // Test IsAlreadyOpen() here even though AudacityProject::MRUOpen() also now checks,
831  // because we don't want to RemoveFileFromHistory() just because it already exists,
832  // and AudacityApp::OnMacOpenFile() calls MRUOpen() directly.
833  // that method does not return the bad result.
834  // PRL: Don't call SafeMRUOpen
835  // -- if open fails for some exceptional reason of resource exhaustion that
836  // the user can correct, leave the file in history.
837  if (!AudacityProject::IsAlreadyOpen(fullPathStr) && !MRUOpen(fullPathStr))
838  mRecentFiles->RemoveFileFromHistory(n);
839 }
static bool IsAlreadyOpen(const wxString &projPathName)
Definition: Project.cpp:2867
#define ID_RECENT_FIRST
bool MRUOpen(const wxString &fileName)
std::unique_ptr< FileHistory > mRecentFiles
Definition: AudacityApp.h:180
void AudacityApp::OnQueryEndSession ( wxCloseEvent &  event)

Definition at line 2103 of file AudacityApp.cpp.

References OnEndSession().

2104 {
2105  bool mustVeto = false;
2106 
2107 #ifdef __WXMAC__
2108  mustVeto = wxDialog::OSXHasModalDialogsOpen();
2109 #endif
2110 
2111  if ( mustVeto )
2112  event.Veto(true);
2113  else
2114  OnEndSession(event);
2115 }
void OnEndSession(wxCloseEvent &event)
void AudacityApp::OnReceiveCommand ( AppCommandEvent event)

Definition at line 1666 of file AudacityApp.cpp.

References mCmdHandler.

1667 {
1668  wxASSERT(NULL != mCmdHandler);
1669  mCmdHandler->OnReceiveCommand(event);
1670 }
std::unique_ptr< CommandHandler > mCmdHandler
Definition: AudacityApp.h:179
void AudacityApp::OnServerEvent ( wxSocketEvent &  evt)
void AudacityApp::OnSocketEvent ( wxSocketEvent &  evt)
void AudacityApp::OnTimer ( wxTimerEvent &  event)

Definition at line 841 of file AudacityApp.cpp.

References _(), GetActiveProject(), gInited, m_LastMissingBlockFileLock, m_LastMissingBlockFilePath, m_LastMissingBlockFileProject, name, SafeMRUOpen(), SetMissingAliasedFileWarningShouldShow(), ShouldShowMissingAliasedFileWarning(), and ShowAliasMissingDialog().

842 {
843  // Filenames are queued when Audacity receives a few of the
844  // AppleEvent messages (via wxWidgets). So, open any that are
845  // in the queue and clean the queue.
846  if (gInited) {
847  if (ofqueue.GetCount()) {
848  // Load each file on the queue
849  while (ofqueue.GetCount()) {
850  wxString name;
851  name.swap(ofqueue[0]);
852  ofqueue.RemoveAt(0);
853 
854  // Get the user's attention if no file name was specified
855  if (name.IsEmpty()) {
856  // Get the users attention
857  AudacityProject *project = GetActiveProject();
858  if (project) {
859  project->Maximize();
860  project->Raise();
861  project->RequestUserAttention();
862  }
863  continue;
864  }
865 
866  // TODO: Handle failures better.
867  // Some failures are OK, e.g. file not found, just would-be-nices to do better,
868  // so FAIL_MSG is more a case of an enhancement request than an actual problem.
869  // LL: In all but one case an appropriate message is already displayed. The
870  // instance that a message is NOT displayed is when a failure to write
871  // to the config file has occurred.
872  // PRL: Catch any exceptions, don't try this file again, continue to
873  // other files.
874  if (!SafeMRUOpen(name)) {
875  wxFAIL_MSG(wxT("MRUOpen failed"));
876  }
877  }
878  }
879  }
880 
881  // Check if a warning for missing aliased files should be displayed
883  // find which project owns the blockfile
884  // note: there may be more than 1, but just go with the first one.
885  //size_t numProjects = gAudacityProjects.size();
886  AProjectHolder offendingProject;
887  wxString missingFileName;
888 
889  {
891  offendingProject = m_LastMissingBlockFileProject.lock();
892  missingFileName = m_LastMissingBlockFilePath;
893  }
894 
895  // if there are no projects open, don't show the warning (user has closed it)
896  if (offendingProject) {
897  offendingProject->Iconize(false);
898  offendingProject->Raise();
899 
900  wxString errorMessage = wxString::Format(_(
901 "One or more external audio files could not be found.\n\
902 It is possible they were moved, deleted, or the drive they \
903 were on was unmounted.\n\
904 Silence is being substituted for the affected audio.\n\
905 The first detected missing file is:\n\
906 %s\n\
907 There may be additional missing files.\n\
908 Choose Help > Diagnostics > Check Dependencies to view a list of \
909 locations of the missing files."), missingFileName);
910 
911  // if an old dialog exists, raise it if it is
912  if (offendingProject->GetMissingAliasFileDialog()) {
913  offendingProject->GetMissingAliasFileDialog()->Raise();
914  } else {
915  ShowAliasMissingDialog(offendingProject.get(), _("Files Missing"),
916  errorMessage, wxT(""), true);
917  }
918  }
919  // Only show this warning once per event (playback/menu item/etc).
921  }
922 }
void SetMissingAliasedFileWarningShouldShow(bool b)
Changes the behavior of missing aliased blockfiles warnings.
std::weak_ptr< AudacityProject > m_LastMissingBlockFileProject
Definition: AudacityApp.h:189
ODLock m_LastMissingBlockFileLock
Definition: AudacityApp.h:192
std::shared_ptr< AudacityProject > AProjectHolder
Definition: Project.h:119
bool ShouldShowMissingAliasedFileWarning()
Returns true if the user should be notified of missing alias warnings.
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
wxString m_LastMissingBlockFilePath
Definition: AudacityApp.h:190
bool SafeMRUOpen(const wxString &fileName)
static wxArrayString ofqueue
void ShowAliasMissingDialog(AudacityProject *parent, const wxString &dlogTitle, const wxString &message, const wxString &helpPage, const bool Close)
Displays a custom modeless error dialog for aliased file errors.
static bool gInited
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
const wxChar * name
Definition: Distortion.cpp:94
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
std::unique_ptr< wxCmdLineParser > AudacityApp::ParseCommandLine ( )
private

Definition at line 2015 of file AudacityApp.cpp.

References _().

Referenced by CreateSingleInstanceChecker(), and OnInit().

2016 {
2017  auto parser = std::make_unique<wxCmdLineParser>(argc, argv);
2018  if (!parser)
2019  {
2020  return nullptr;
2021  }
2022 
2023  /*i18n-hint: This controls the number of bytes that Audacity will
2024  * use when writing files to the disk */
2025  parser->AddOption(wxT("b"), wxT("blocksize"), _("set max disk block size in bytes"),
2026  wxCMD_LINE_VAL_NUMBER);
2027 
2028  /*i18n-hint: This decodes an autosave file */
2029  parser->AddOption(wxT("d"), wxT("decode"), _("decode an autosave file"),
2030  wxCMD_LINE_VAL_STRING);
2031 
2032  /*i18n-hint: This displays a list of available options */
2033  parser->AddSwitch(wxT("h"), wxT("help"), _("this help message"),
2034  wxCMD_LINE_OPTION_HELP);
2035 
2036  /*i18n-hint: This runs a set of automatic tests on Audacity itself */
2037  parser->AddSwitch(wxT("t"), wxT("test"), _("run self diagnostics"));
2038 
2039  /*i18n-hint: This displays the Audacity version */
2040  parser->AddSwitch(wxT("v"), wxT("version"), _("display Audacity version"));
2041 
2042  /*i18n-hint: This is a list of one or more files that Audacity
2043  * should open upon startup */
2044  parser->AddParam(_("audio or project file name"),
2045  wxCMD_LINE_VAL_STRING,
2046  wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL);
2047 
2048  // Run the parser
2049  if (parser->Parse() == 0)
2050  return parser;
2051 
2052  return{};
2053 }
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
bool AudacityApp::SafeMRUOpen ( const wxString &  fileName)

Definition at line 812 of file AudacityApp.cpp.

References MRUOpen().

Referenced by OnInit(), and OnTimer().

813 {
814  return GuardedCall< bool >( [&]{ return MRUOpen( fullPathStr ); } );
815 }
bool MRUOpen(const wxString &fileName)
void AudacityApp::SetMissingAliasedFileWarningShouldShow ( bool  b)

Changes the behavior of missing aliased blockfiles warnings.

Definition at line 946 of file AudacityApp.cpp.

References m_aliasMissingWarningShouldShow, and MarkAliasedFilesMissingWarning().

Referenced by AudacityProject::AudacityProject(), AudacityProject::DoEffect(), AudacityProject::ExportFromTimerRecording(), AudacityProject::HandleMixAndRender(), AudacityProject::OnExport(), AudacityProject::OnExportMultiple(), AudacityProject::OnExportSelection(), AudacityProject::OnImport(), OnTimer(), DirManager::ProjectFSCK(), and AudioIO::StartStream().

947 {
948  // Note that this is can be called by both the main thread and other threads.
949  // I don't believe we need a mutex because we are checking zero vs non-zero,
950  // and the setting from other threads will always be non-zero (true), and the
951  // setting from the main thread is always false.
953  // reset the warnings as they were probably marked by a previous run
956  }
957 }
bool m_aliasMissingWarningShouldShow
Definition: AudacityApp.h:188
void MarkAliasedFilesMissingWarning(const AliasBlockFile *b)
Mark playback as having missing aliased blockfiles.
void AudacityApp::SetVersionKeysInit ( int  major,
int  minor,
int  micro 
)
inline

Definition at line 172 of file AudacityApp.h.

References mVersionMajorKeyInit, mVersionMicroKeyInit, and mVersionMinorKeyInit.

Referenced by InitPreferences().

int mVersionMajorKeyInit
Definition: AudacityApp.h:210
int mVersionMicroKeyInit
Definition: AudacityApp.h:212
int mVersionMinorKeyInit
Definition: AudacityApp.h:211
void AudacityApp::SetWindowRectAlreadySaved ( bool  alreadySaved)
inline

Definition at line 157 of file AudacityApp.h.

References mWindowRectAlreadySaved.

Referenced by AudacityProject::OnCloseWindow(), and SaveWindowSize().

157 {mWindowRectAlreadySaved = alreadySaved;}
bool mWindowRectAlreadySaved
Definition: AudacityApp.h:201
bool AudacityApp::ShouldShowMissingAliasedFileWarning ( )

Returns true if the user should be notified of missing alias warnings.

Definition at line 959 of file AudacityApp.cpp.

References m_aliasMissingWarningShouldShow, m_LastMissingBlockFileLock, and m_LastMissingBlockFileProject.

Referenced by OnTimer().

960 {
962  auto ptr = m_LastMissingBlockFileProject.lock();
963  return ptr && m_aliasMissingWarningShouldShow;
964 }
std::weak_ptr< AudacityProject > m_LastMissingBlockFileProject
Definition: AudacityApp.h:189
bool m_aliasMissingWarningShouldShow
Definition: AudacityApp.h:188
ODLock m_LastMissingBlockFileLock
Definition: AudacityApp.h:192

Member Data Documentation

wxArrayString AudacityApp::audacityPathList

A list of directories that should be searched for Audacity files (plug-ins, help files, etc.).

On Unix this will include the directory Audacity was installed into, plus the current user's .audacity-data/Plug-Ins directory. Additional directories can be specified using the AUDACITY_PATH environment variable. On Windows or Mac OS, this will include the directory which contains the Audacity program.

Definition at line 138 of file AudacityApp.h.

Referenced by GetLanguages(), NyquistEffect::GetNyquistSearchPath(), NyquistEffectsModule::Initialize(), ModuleManager::Initialize(), InitLang(), and OnInit().

wxString AudacityApp::defaultTempDir

Default temp directory.

Definition at line 141 of file AudacityApp.h.

Referenced by InitTempDir(), DirectoriesPrefs::OnChooseTempDir(), and OnInit().

bool AudacityApp::m_aliasMissingWarningShouldShow
private
ODLock AudacityApp::m_LastMissingBlockFileLock
private
wxString AudacityApp::m_LastMissingBlockFilePath
private

Definition at line 190 of file AudacityApp.h.

Referenced by MarkAliasedFilesMissingWarning(), and OnTimer().

std::weak_ptr< AudacityProject > AudacityApp::m_LastMissingBlockFileProject
private
std::unique_ptr<wxSingleInstanceChecker> AudacityApp::mChecker
private

Definition at line 184 of file AudacityApp.h.

Referenced by CreateSingleInstanceChecker().

std::unique_ptr<CommandHandler> AudacityApp::mCmdHandler
private

Definition at line 179 of file AudacityApp.h.

Referenced by InitCommandHandler(), OnInit(), and OnReceiveCommand().

std::unique_ptr<wxSocketServer> AudacityApp::mIPCServ
private

Definition at line 206 of file AudacityApp.h.

Referenced by CreateSingleInstanceChecker(), and OnExit().

std::unique_ptr<wxLocale> AudacityApp::mLocale
private

Definition at line 182 of file AudacityApp.h.

Referenced by InitLang(), and OnInit().

std::unique_ptr<FileHistory> AudacityApp::mRecentFiles
private

Definition at line 180 of file AudacityApp.h.

Referenced by AddFileToHistory(), GetRecentFiles(), OnExit(), OnInit(), OnMRUClear(), and OnMRUFile().

wxTimer AudacityApp::mTimer
private

Definition at line 186 of file AudacityApp.h.

Referenced by OnInit().

int AudacityApp::mVersionMajorKeyInit {}
private

Definition at line 210 of file AudacityApp.h.

Referenced by GetVersionKeysInit(), and SetVersionKeysInit().

int AudacityApp::mVersionMicroKeyInit {}
private

Definition at line 212 of file AudacityApp.h.

Referenced by GetVersionKeysInit(), and SetVersionKeysInit().

int AudacityApp::mVersionMinorKeyInit {}
private

Definition at line 211 of file AudacityApp.h.

Referenced by GetVersionKeysInit(), and SetVersionKeysInit().

bool AudacityApp::mWindowRectAlreadySaved
private

Definition at line 201 of file AudacityApp.h.

Referenced by GetWindowRectAlreadySaved(), OnInit(), and SetWindowRectAlreadySaved().


The documentation for this class was generated from the following files: