diff --git a/src/AboutDialog.cpp b/src/AboutDialog.cpp
index 131fd7948..9a52c40d9 100644
--- a/src/AboutDialog.cpp
+++ b/src/AboutDialog.cpp
@@ -285,27 +285,28 @@ visit our forum.");
S.StartNotebookPage( wxT("Audacity") );
S.StartVerticalLay(1);
- //v For now, change to AudacityLogoWithName via old-fashioned way, not Theme.
- wxBitmap *const logo = new wxBitmap((const char **) AudacityLogoWithName_xpm); //v
+ {
+ //v For now, change to AudacityLogoWithName via old-fashioned way, not Theme.
+ wxBitmap logo(AudacityLogoWithName_xpm); //v
- // JKC: Resize to 50% of size. Later we may use a smaller xpm as
- // our source, but this allows us to tweak the size - if we want to.
- // It also makes it easier to revert to full size if we decide to.
- const float fScale=0.5f;// smaller size.
- wxImage RescaledImage( logo->ConvertToImage() );
- // wxIMAGE_QUALITY_HIGH not supported by wxWidgets 2.6.1, or we would use it here.
- RescaledImage.Rescale( int(LOGOWITHNAME_WIDTH * fScale), int(LOGOWITHNAME_HEIGHT *fScale) );
- wxBitmap RescaledBitmap( RescaledImage );
+ // JKC: Resize to 50% of size. Later we may use a smaller xpm as
+ // our source, but this allows us to tweak the size - if we want to.
+ // It also makes it easier to revert to full size if we decide to.
+ const float fScale = 0.5f;// smaller size.
+ wxImage RescaledImage(logo.ConvertToImage());
+ // wxIMAGE_QUALITY_HIGH not supported by wxWidgets 2.6.1, or we would use it here.
+ RescaledImage.Rescale(int(LOGOWITHNAME_WIDTH * fScale), int(LOGOWITHNAME_HEIGHT *fScale));
+ wxBitmap RescaledBitmap(RescaledImage);
- icon =
- safenew wxStaticBitmap(S.GetParent(), -1,
- //*logo, //v
- //v theTheme.Bitmap(bmpAudacityLogo), wxPoint(93, 10), wxSize(215, 190));
- //v theTheme.Bitmap(bmpAudacityLogoWithName),
- RescaledBitmap,
- wxDefaultPosition,
- wxSize(int(LOGOWITHNAME_WIDTH*fScale), int(LOGOWITHNAME_HEIGHT*fScale)));
- delete logo;
+ icon =
+ safenew wxStaticBitmap(S.GetParent(), -1,
+ //*logo, //v
+ //v theTheme.Bitmap(bmpAudacityLogo), wxPoint(93, 10), wxSize(215, 190));
+ //v theTheme.Bitmap(bmpAudacityLogoWithName),
+ RescaledBitmap,
+ wxDefaultPosition,
+ wxSize(int(LOGOWITHNAME_WIDTH*fScale), int(LOGOWITHNAME_HEIGHT*fScale)));
+ }
S.Prop(0).AddWindow( icon );
HtmlWindow *html = safenew LinkingHtmlWindow(S.GetParent(), -1,
diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp
index 120ba1fea..8db48eef8 100644
--- a/src/AudacityApp.cpp
+++ b/src/AudacityApp.cpp
@@ -1159,7 +1159,7 @@ bool AudacityApp::OnInit()
#if defined(__WXMAC__)
// Disable window animation
- wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
+ wxSystemOptions::SetOption(wxMAC_WINDOW_PLAIN_TRANSITION, 1);
#endif
#ifdef AUDACITY_NAME
@@ -1203,32 +1203,32 @@ bool AudacityApp::OnInit()
#ifdef AUDACITY_NAME
AddUniquePathToPathList(wxString::Format(wxT("%s/.%s-files"),
- home.c_str(), wxT(AUDACITY_NAME)),
- audacityPathList);
+ home.c_str(), wxT(AUDACITY_NAME)),
+ audacityPathList);
AddUniquePathToPathList(wxString::Format(wxT("%s/share/%s"),
- wxT(INSTALL_PREFIX), wxT(AUDACITY_NAME)),
- audacityPathList);
+ wxT(INSTALL_PREFIX), wxT(AUDACITY_NAME)),
+ audacityPathList);
AddUniquePathToPathList(wxString::Format(wxT("%s/share/doc/%s"),
- wxT(INSTALL_PREFIX), wxT(AUDACITY_NAME)),
- audacityPathList);
+ wxT(INSTALL_PREFIX), wxT(AUDACITY_NAME)),
+ audacityPathList);
#else //AUDACITY_NAME
AddUniquePathToPathList(wxString::Format(wxT("%s/.audacity-files"),
- home.c_str()),
- audacityPathList);
+ home.c_str()),
+ audacityPathList);
AddUniquePathToPathList(wxString::Format(wxT("%s/share/audacity"),
- wxT(INSTALL_PREFIX)),
- audacityPathList);
+ wxT(INSTALL_PREFIX)),
+ audacityPathList);
AddUniquePathToPathList(wxString::Format(wxT("%s/share/doc/audacity"),
- wxT(INSTALL_PREFIX)),
- audacityPathList);
+ wxT(INSTALL_PREFIX)),
+ audacityPathList);
#endif //AUDACITY_NAME
AddUniquePathToPathList(wxString::Format(wxT("%s/share/locale"),
- wxT(INSTALL_PREFIX)),
- audacityPathList);
+ wxT(INSTALL_PREFIX)),
+ audacityPathList);
AddUniquePathToPathList(wxString::Format(wxT("./locale")),
- audacityPathList);
+ audacityPathList);
#endif //__WXGTK__
@@ -1242,12 +1242,12 @@ bool AudacityApp::OnInit()
// On Windows, the path to the Audacity program is in argv[0]
wxString progPath = wxPathOnly(argv[0]);
AddUniquePathToPathList(progPath, audacityPathList);
- AddUniquePathToPathList(progPath+wxT("\\Languages"), audacityPathList);
+ AddUniquePathToPathList(progPath + wxT("\\Languages"), audacityPathList);
// See bug #1271 for explanation of location
tmpDirLoc = FileNames::MkDir(wxStandardPaths::Get().GetUserLocalDataDir());
defaultTempDir.Printf(wxT("%s\\SessionData"),
- tmpDirLoc.c_str());
+ tmpDirLoc.c_str());
#endif //__WXWSW__
#ifdef __WXMAC__
@@ -1257,15 +1257,15 @@ bool AudacityApp::OnInit()
AddUniquePathToPathList(progPath, audacityPathList);
// If Audacity is a "bundle" package, then the root directory is
// the great-great-grandparent of the directory containing the executable.
- AddUniquePathToPathList(progPath+wxT("/../../../"), audacityPathList);
+ AddUniquePathToPathList(progPath + wxT("/../../../"), audacityPathList);
// These allow for searching the "bundle"
- AddUniquePathToPathList(progPath+wxT("/../"), audacityPathList);
- AddUniquePathToPathList(progPath+wxT("/../Resources"), audacityPathList);
+ AddUniquePathToPathList(progPath + wxT("/../"), audacityPathList);
+ AddUniquePathToPathList(progPath + wxT("/../Resources"), audacityPathList);
defaultTempDir.Printf(wxT("%s/audacity-%s"),
- tmpDirLoc.c_str(),
- wxGetUserId().c_str());
+ tmpDirLoc.c_str(),
+ wxGetUserId().c_str());
#endif //__WXMAC__
// Define languanges for which we have translations, but that are not yet
@@ -1283,9 +1283,9 @@ bool AudacityApp::OnInit()
// Initialize preferences and language
InitPreferences();
- #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__CYGWIN__)
- this->AssociateFileTypes();
- #endif
+#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__CYGWIN__)
+ this->AssociateFileTypes();
+#endif
// TODO - read the number of files to store in history from preferences
mRecentFiles = new FileHistory(ID_RECENT_LAST - ID_RECENT_FIRST + 1, ID_RECENT_CLEAR);
@@ -1303,10 +1303,10 @@ bool AudacityApp::OnInit()
return false;
}
-//<<<< Try to avoid dialogs before this point.
-// The reason is that InitTempDir starts the single instance checker.
-// If we're waiitng in a dialog before then we can very easily
-// start multiple instances, defeating the single instance checker.
+ //<<<< Try to avoid dialogs before this point.
+ // The reason is that InitTempDir starts the single instance checker.
+ // If we're waiitng in a dialog before then we can very easily
+ // start multiple instances, defeating the single instance checker.
// Initialize the CommandHandler
InitCommandHandler();
@@ -1367,68 +1367,70 @@ bool AudacityApp::OnInit()
}
// BG: Create a temporary window to set as the top window
- wxImage logoimage((const char **) AudacityLogoWithName_xpm);
+ wxImage logoimage((const char **)AudacityLogoWithName_xpm);
logoimage.Rescale(logoimage.GetWidth() / 2, logoimage.GetHeight() / 2);
wxBitmap logo(logoimage);
- wxSplashScreen *temporarywindow =
- new wxSplashScreen(logo,
- wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT,
- 0,
- NULL,
- wxID_ANY,
- wxDefaultPosition,
- wxDefaultSize,
- wxSTAY_ON_TOP);
- temporarywindow->SetTitle(_("Audacity is starting up..."));
- SetTopWindow(temporarywindow);
- wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
+ AudacityProject *project;
+ {
+ wxSplashScreen temporarywindow(
+ logo,
+ wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT,
+ 0,
+ NULL,
+ wxID_ANY,
+ wxDefaultPosition,
+ wxDefaultSize,
+ wxSTAY_ON_TOP);
+ temporarywindow.SetTitle(_("Audacity is starting up..."));
+ SetTopWindow(&temporarywindow);
+ wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
- //JKC: Would like to put module loading here.
+ //JKC: Would like to put module loading here.
- // More initialization
+ // More initialization
- InitDitherers();
- InitAudioIO();
+ InitDitherers();
+ InitAudioIO();
#ifdef __WXMAC__
- // On the Mac, users don't expect a program to quit when you close the last window.
- // Create a menubar that will show when all project windows are closed.
+ // On the Mac, users don't expect a program to quit when you close the last window.
+ // Create a menubar that will show when all project windows are closed.
- wxMenu *fileMenu = new wxMenu();
- wxMenu *recentMenu = new wxMenu();
- fileMenu->Append(wxID_NEW, wxString(_("&New")) + wxT("\tCtrl+N"));
- fileMenu->Append(wxID_OPEN, wxString(_("&Open...")) + wxT("\tCtrl+O"));
- fileMenu->AppendSubMenu(recentMenu, _("Open &Recent..."));
- fileMenu->Append(wxID_ABOUT, _("&About Audacity..."));
- fileMenu->Append(wxID_PREFERENCES, wxString(_("&Preferences...")) + wxT("\tCtrl+,"));
+ wxMenu *fileMenu = new wxMenu();
+ wxMenu *recentMenu = new wxMenu();
+ fileMenu->Append(wxID_NEW, wxString(_("&New")) + wxT("\tCtrl+N"));
+ fileMenu->Append(wxID_OPEN, wxString(_("&Open...")) + wxT("\tCtrl+O"));
+ fileMenu->AppendSubMenu(recentMenu, _("Open &Recent..."));
+ fileMenu->Append(wxID_ABOUT, _("&About Audacity..."));
+ fileMenu->Append(wxID_PREFERENCES, wxString(_("&Preferences...")) + wxT("\tCtrl+,"));
- wxMenuBar *menuBar = new wxMenuBar();
- menuBar->Append(fileMenu, _("&File"));
+ wxMenuBar *menuBar = new wxMenuBar();
+ menuBar->Append(fileMenu, _("&File"));
- wxMenuBar::MacSetCommonMenuBar(menuBar);
+ wxMenuBar::MacSetCommonMenuBar(menuBar);
- mRecentFiles->UseMenu(recentMenu);
- mRecentFiles->AddFilesToMenu(recentMenu);
+ mRecentFiles->UseMenu(recentMenu);
+ mRecentFiles->AddFilesToMenu(recentMenu);
- SetExitOnFrameDelete(false);
+ SetExitOnFrameDelete(false);
#endif //__WXMAC__
- AudacityProject *project = CreateNewAudacityProject();
- mCmdHandler->SetProject(project);
- wxWindow * pWnd = MakeHijackPanel() ;
- if( pWnd )
- {
- project->Show( false );
- pWnd->SetParent( project );
- SetTopWindow(pWnd);
- pWnd->Show( true );
- }
+ project = CreateNewAudacityProject();
+ mCmdHandler->SetProject(project);
+ wxWindow * pWnd = MakeHijackPanel();
+ if (pWnd)
+ {
+ project->Show(false);
+ pWnd->SetParent(project);
+ SetTopWindow(pWnd);
+ pWnd->Show(true);
+ }
- temporarywindow->Show(false);
- delete temporarywindow;
+ temporarywindow.Show(false);
+ }
if( project->mShowSplashScreen )
project->OnHelpWelcome();
diff --git a/src/AudacityLogger.cpp b/src/AudacityLogger.cpp
index ac8ad6a2d..480b3934f 100644
--- a/src/AudacityLogger.cpp
+++ b/src/AudacityLogger.cpp
@@ -170,19 +170,19 @@ void AudacityLogger::Show(bool show)
frame->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
// loads either the XPM or the windows resource, depending on the platform
+ {
#if !defined(__WXMAC__) && !defined(__WXX11__)
- wxIcon *ic;
- #if defined(__WXMSW__)
- ic = new wxIcon(wxICON(AudacityLogo));
- #elif defined(__WXGTK__)
- ic = new wxIcon(wxICON(AudacityLogoAlpha));
- #else
- ic = new wxIcon();
+#if defined(__WXMSW__)
+ wxIcon ic{wxICON(AudacityLogo)};
+#elif defined(__WXGTK__)
+ wxIcon ic{wxICON(AudacityLogoAlpha)};
+#else
+ wxIcon ic{};
ic.CopyFromBitmap(theTheme.Bitmap(bmpAudacityLogo48x48));
- #endif
- frame->SetIcon(*ic);
- delete ic;
#endif
+ frame->SetIcon(ic);
+#endif
+ }
// Log text
ShuttleGui S(frame, eIsCreating);
diff --git a/src/AutoRecovery.cpp b/src/AutoRecovery.cpp
index 7ff3ae20c..5e5d650f3 100644
--- a/src/AutoRecovery.cpp
+++ b/src/AutoRecovery.cpp
@@ -248,9 +248,7 @@ bool ShowAutoRecoveryDialogIfNeeded(AudacityProject** pproj,
// This must be done before "dlg" is declared.
wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
- AutoRecoveryDialog *dlg = new AutoRecoveryDialog(NULL); //*pproj);
- int ret = dlg->ShowModal();
- delete dlg;
+ int ret = AutoRecoveryDialog{nullptr}.ShowModal();
switch (ret)
{
diff --git a/src/BatchProcessDialog.cpp b/src/BatchProcessDialog.cpp
index c54a9e6bb..4205cef9f 100644
--- a/src/BatchProcessDialog.cpp
+++ b/src/BatchProcessDialog.cpp
@@ -188,9 +188,11 @@ void BatchProcessDialog::OnApplyToProject(wxCommandEvent & WXUNUSED(event))
// The disabler must get deleted before the EndModal() call. Otherwise,
// the menus on OSX will remain disabled.
- wxWindowDisabler *wd = new wxWindowDisabler(pD);
- bool success = mBatchCommands.ApplyChain();
- delete wd;
+ bool success;
+ {
+ wxWindowDisabler wd(pD);
+ success = mBatchCommands.ApplyChain();
+ }
if (!success) {
Show();
diff --git a/src/Benchmark.cpp b/src/Benchmark.cpp
index 12efdf4dc..2d05d7317 100644
--- a/src/Benchmark.cpp
+++ b/src/Benchmark.cpp
@@ -344,8 +344,7 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
ZoomInfo zoomInfo(0.0, ZoomInfo::GetDefaultZoom());
DirManager *d = new DirManager();
- TrackFactory *fact = new TrackFactory(d, &zoomInfo);
- WaveTrack *t = fact->NewWaveTrack(int16Sample);
+ WaveTrack *const t = TrackFactory{ d, &zoomInfo }.NewWaveTrack(int16Sample);
Track *tmp = NULL;
t->SetRate(1);
@@ -540,7 +539,6 @@ void BenchmarkDialog::OnRun( wxCommandEvent & WXUNUSED(event))
delete[]small2;
delete[]block;
- delete fact;
d->Deref();
Sequence::SetMaxDiskBlockSize(oldBlockSize);
diff --git a/src/Dependencies.cpp b/src/Dependencies.cpp
index 64d7ffc5c..5bbaff43c 100644
--- a/src/Dependencies.cpp
+++ b/src/Dependencies.cpp
@@ -165,9 +165,9 @@ static void RemoveDependencies(AudacityProject *project,
{
DirManager *dirManager = project->GetDirManager();
- ProgressDialog *progress =
- new ProgressDialog(_("Removing Dependencies"),
- _("Copying audio data into project..."));
+ ProgressDialog progress
+ (_("Removing Dependencies"),
+ _("Copying audio data into project..."));
int updateResult = eProgressSuccess;
// Hash aliasedFiles based on their full paths and
@@ -215,7 +215,7 @@ static void RemoveDependencies(AudacityProject *project,
// Update the progress bar
completedBytes += SAMPLE_SIZE(format) * len;
- updateResult = progress->Update(completedBytes, totalBytesToProcess);
+ updateResult = progress.Update(completedBytes, totalBytesToProcess);
if (updateResult != eProgressSuccess)
break;
}
@@ -235,8 +235,6 @@ static void RemoveDependencies(AudacityProject *project,
BlockFile *f = it->second;
dirManager->Deref(f);
}
-
- delete progress;
}
//
diff --git a/src/DirManager.cpp b/src/DirManager.cpp
index d36401385..d2f52b87d 100644
--- a/src/DirManager.cpp
+++ b/src/DirManager.cpp
@@ -445,64 +445,62 @@ bool DirManager::SetProject(wxString& newProjPath, wxString& newProjName, const
saved version of the old project must not be moved,
otherwise the old project would not be safe.) */
- /*i18n-hint: This title appears on a dialog that indicates the progress in doing something.*/
- ProgressDialog *progress = new ProgressDialog(_("Progress"),
- _("Saving project data files"));
-
- int total = mBlockFileHash.size();
- int count=0;
-
- BlockHash::iterator iter = mBlockFileHash.begin();
- bool success = true;
- while ((iter != mBlockFileHash.end()) && success)
{
- BlockFile *b = iter->second;
+ /*i18n-hint: This title appears on a dialog that indicates the progress in doing something.*/
+ ProgressDialog progress(_("Progress"),
+ _("Saving project data files"));
- if (b->IsLocked())
- success = CopyToNewProjectDirectory(b);
- else{
- success = MoveToNewProjectDirectory(b);
- }
-
- progress->Update(count, total);
-
- ++iter;
- count++;
- }
-
- if (!success) {
- // If the move failed, we try to move/copy as many files
- // back as possible so that no damage was done. (No sense
- // in checking for errors this time around - there's nothing
- // that could be done about it.)
- // Likely causes: directory was not writeable, disk was full
-
- projFull = oldLoc;
+ int total = mBlockFileHash.size();
BlockHash::iterator iter = mBlockFileHash.begin();
- while (iter != mBlockFileHash.end())
+ bool success = true;
+ int count = 0;
+ while ((iter != mBlockFileHash.end()) && success)
{
BlockFile *b = iter->second;
- MoveToNewProjectDirectory(b);
- if (count>=0)
- progress->Update(count, total);
+ if (b->IsLocked())
+ success = CopyToNewProjectDirectory(b);
+ else{
+ success = MoveToNewProjectDirectory(b);
+ }
+
+ progress.Update(count, total);
++iter;
- count--;
+ count++;
}
- this->projFull = oldFull;
- this->projPath = oldPath;
- this->projName = oldName;
+ if (!success) {
+ // If the move failed, we try to move/copy as many files
+ // back as possible so that no damage was done. (No sense
+ // in checking for errors this time around - there's nothing
+ // that could be done about it.)
+ // Likely causes: directory was not writeable, disk was full
- delete progress;
+ projFull = oldLoc;
- return false;
+ BlockHash::iterator iter = mBlockFileHash.begin();
+ while (iter != mBlockFileHash.end())
+ {
+ BlockFile *b = iter->second;
+ MoveToNewProjectDirectory(b);
+
+ if (count >= 0)
+ progress.Update(count, total);
+
+ ++iter;
+ count--;
+ }
+
+ this->projFull = oldFull;
+ this->projPath = oldPath;
+ this->projName = oldName;
+
+ return false;
+ }
}
- delete progress;
-
// Some subtlety; SetProject is used both to move a temp project
// into a permanent home as well as just set up path variables when
// loading a project; in this latter case, the movement code does
@@ -515,7 +513,7 @@ bool DirManager::SetProject(wxString& newProjPath, wxString& newProjName, const
// NEW; rmdir will fail on non-empty dirs.
wxArrayString dirlist;
- count = RecursivelyEnumerate(cleanupLoc1, dirlist, wxEmptyString, false, true);
+ const int count = RecursivelyEnumerate(cleanupLoc1, dirlist, wxEmptyString, false, true);
//This destroys the empty dirs of the OD block files, which are yet to come.
//Dont know if this will make the project dirty, but I doubt it. (mchinen)
@@ -1653,13 +1651,12 @@ other projects. \
if ((nResult != FSCKstatus_CLOSE_REQ) && !ODManager::HasLoadedODFlag())
{
// Remove any empty directories.
- ProgressDialog* pProgress =
- new ProgressDialog(_("Progress"),
- _("Cleaning up unused directories in project data"));
+ ProgressDialog pProgress
+ (_("Progress"),
+ _("Cleaning up unused directories in project data"));
// nDirCount is for updating pProgress. +1 because we may DELETE dirPath.
int nDirCount = RecursivelyCountSubdirs(dirPath) + 1;
- RecursivelyRemoveEmptyDirs(dirPath, nDirCount, pProgress);
- delete pProgress;
+ RecursivelyRemoveEmptyDirs(dirPath, nDirCount, &pProgress);
}
// Summarize and flush the log.
diff --git a/src/FFmpeg.cpp b/src/FFmpeg.cpp
index 7fb52fb40..741dd53e2 100644
--- a/src/FFmpeg.cpp
+++ b/src/FFmpeg.cpp
@@ -692,14 +692,9 @@ bool FFmpegLibs::LoadLibs(wxWindow * WXUNUSED(parent), bool showerr)
{
wxLogError(wxT("Failed to load libraries altogether."));
int dontShowDlg;
- FFmpegNotFoundDialog *dlg;
gPrefs->Read(wxT("/FFmpeg/NotFoundDontShow"),&dontShowDlg,0);
if ((dontShowDlg == 0) && (showerr))
- {
- dlg = new FFmpegNotFoundDialog(NULL);
- dlg->ShowModal();
- delete dlg;
- }
+ FFmpegNotFoundDialog{nullptr}.ShowModal();
}
*/
// Oh well, just give up
diff --git a/src/FreqWindow.cpp b/src/FreqWindow.cpp
index c67abb699..db56b1eb4 100644
--- a/src/FreqWindow.cpp
+++ b/src/FreqWindow.cpp
@@ -1001,14 +1001,14 @@ void FreqWindow::Recalc()
// just the mProgress window with the idea of preventing user interaction with the
// controls while the plot was being recalculated. This doesn't appear to be necessary
// so just use the the top level window instead.
- wxWindowDisabler *blocker = new wxWindowDisabler(this);
- wxYieldIfNeeded();
+ {
+ wxWindowDisabler blocker(this);
+ wxYieldIfNeeded();
- mAnalyst->Calculate(alg, windowFunc, mWindowSize, mRate,
- mData, mDataLen,
- &mYMin, &mYMax, mProgress);
-
- delete blocker;
+ mAnalyst->Calculate(alg, windowFunc, mWindowSize, mRate,
+ mData, mDataLen,
+ &mYMin, &mYMax, mProgress);
+ }
if (hadFocus) {
hadFocus->SetFocus();
}
@@ -1033,16 +1033,14 @@ void FreqWindow::OnExport(wxCommandEvent & WXUNUSED(event))
wxString fName = _("spectrum.txt");
fName = FileSelector(_("Export Spectral Data As:"),
- wxEmptyString, fName, wxT("txt"), wxT("*.txt"), wxFD_SAVE | wxRESIZE_BORDER, this);
+ wxEmptyString, fName, wxT("txt"), wxT("*.txt"), wxFD_SAVE | wxRESIZE_BORDER, this);
if (fName == wxT(""))
return;
wxTextFile f(fName);
#ifdef __WXMAC__
- wxFile *temp = new wxFile();
- temp->Create(fName);
- delete temp;
+ wxFile{}.Create(fName);
#else
f.Create();
#endif
diff --git a/src/LabelDialog.cpp b/src/LabelDialog.cpp
index ad0bf463b..8bc0cba52 100644
--- a/src/LabelDialog.cpp
+++ b/src/LabelDialog.cpp
@@ -589,12 +589,12 @@ void LabelDialog::OnExport(wxCommandEvent & WXUNUSED(event))
wxString fName = mTrackNames[mTrackNames.GetCount() - 1].AfterFirst(wxT('-')).Mid(1);
fName = FileSelector(_("Export Labels As:"),
- wxEmptyString,
- fName.c_str(),
- wxT("txt"),
- wxT("*.txt"),
- wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
- this);
+ wxEmptyString,
+ fName.c_str(),
+ wxT("txt"),
+ wxT("*.txt"),
+ wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
+ this);
if (fName == wxT(""))
return;
@@ -617,9 +617,7 @@ void LabelDialog::OnExport(wxCommandEvent & WXUNUSED(event))
wxTextFile f(fName);
#ifdef __WXMAC__
- wxFile *temp = new wxFile();
- temp->Create(fName);
- delete temp;
+ wxFile{}.Create(fName);
#else
f.Create();
#endif
diff --git a/src/LabelTrack.cpp b/src/LabelTrack.cpp
index d35e7ec35..aa57b6a1a 100644
--- a/src/LabelTrack.cpp
+++ b/src/LabelTrack.cpp
@@ -2013,42 +2013,42 @@ void LabelTrack::ShowContextMenu()
{
wxWindow *parent = wxWindow::FindFocus();
- wxMenu *menu = new wxMenu();
- menu->Bind(wxEVT_MENU, &LabelTrack::OnContextMenu, this);
-
- menu->Append(OnCutSelectedTextID, _("Cu&t"));
- menu->Append(OnCopySelectedTextID, _("&Copy"));
- menu->Append(OnPasteSelectedTextID, _("&Paste"));
- menu->Append(OnDeleteSelectedLabelID, _("&Delete Label"));
-
- menu->Enable(OnCutSelectedTextID, IsTextSelected());
- menu->Enable(OnCopySelectedTextID, IsTextSelected());
- menu->Enable(OnPasteSelectedTextID, IsTextClipSupported());
- menu->Enable(OnDeleteSelectedLabelID, true);
-
- const LabelStruct *ls = GetLabel(mSelIndex);
-
- wxClientDC dc(parent);
-
- if (msFont.Ok())
{
- dc.SetFont(msFont);
- }
+ wxMenu menu;
+ menu.Bind(wxEVT_MENU, &LabelTrack::OnContextMenu, this);
- int x;
- if (mMouseXPos != -1)
- {
- x = mMouseXPos;
- }
- else
- {
- dc.GetTextExtent(ls->title.Left(mCurrentCursorPos), &x, NULL);
- x += ls->xText;
- }
+ menu.Append(OnCutSelectedTextID, _("Cu&t"));
+ menu.Append(OnCopySelectedTextID, _("&Copy"));
+ menu.Append(OnPasteSelectedTextID, _("&Paste"));
+ menu.Append(OnDeleteSelectedLabelID, _("&Delete Label"));
- parent->PopupMenu(menu, x, ls->y + (mIconHeight / 2) - 1);
+ menu.Enable(OnCutSelectedTextID, IsTextSelected());
+ menu.Enable(OnCopySelectedTextID, IsTextSelected());
+ menu.Enable(OnPasteSelectedTextID, IsTextClipSupported());
+ menu.Enable(OnDeleteSelectedLabelID, true);
- delete menu;
+ const LabelStruct *ls = GetLabel(mSelIndex);
+
+ wxClientDC dc(parent);
+
+ if (msFont.Ok())
+ {
+ dc.SetFont(msFont);
+ }
+
+ int x;
+ if (mMouseXPos != -1)
+ {
+ x = mMouseXPos;
+ }
+ else
+ {
+ dc.GetTextExtent(ls->title.Left(mCurrentCursorPos), &x, NULL);
+ x += ls->xText;
+ }
+
+ parent->PopupMenu(&menu, x, ls->y + (mIconHeight / 2) - 1);
+ }
// it's an invalid dragging event
SetWrongDragging(true);
diff --git a/src/LyricsWindow.cpp b/src/LyricsWindow.cpp
index 47c97ff32..600e07de7 100644
--- a/src/LyricsWindow.cpp
+++ b/src/LyricsWindow.cpp
@@ -66,15 +66,15 @@ LyricsWindow::LyricsWindow(AudacityProject *parent):
mProject = parent;
// loads either the XPM or the windows resource, depending on the platform
- #if !defined(__WXMAC__) && !defined(__WXX11__)
- wxIcon *ic;
- #ifdef __WXMSW__
- ic = new wxIcon(wxICON(AudacityLogo));
- #else
- ic = new wxIcon(wxICON(AudacityLogo48x48));
- #endif
- SetIcon(*ic);
- delete ic;
+#if !defined(__WXMAC__) && !defined(__WXX11__)
+ {
+#ifdef __WXMSW__
+ wxIcon ic{ wxICON(AudacityLogo) };
+#else
+ wxIcon ic{wxICON(AudacityLogo48x48)};
+#endif
+ SetIcon(ic);
+ }
#endif
wxPoint panelPos(0, 0);
diff --git a/src/Menus.cpp b/src/Menus.cpp
index 228f24b4d..b91b38375 100644
--- a/src/Menus.cpp
+++ b/src/Menus.cpp
@@ -6148,38 +6148,38 @@ void AudacityProject::OnScoreAlign()
mTracks->GetWaveTracks(true /* selectionOnly */,
&numWaveTracksSelected, &waveTracks);
- Mixer *mix = new Mixer(numWaveTracksSelected, // int numInputTracks
- waveTracks, // WaveTrack **inputTracks
- mTracks->GetTimeTrack(), // TimeTrack *timeTrack
- 0.0, // double startTime
- endTime, // double stopTime
- 2, // int numOutChannels
- 44100, // int outBufferSize
- true, // bool outInterleaved
- mRate, // double outRate
- floatSample, // sampleFormat outFormat
- true, // bool highQuality = true
- NULL); // MixerSpec *mixerSpec = NULL
- delete [] waveTracks;
+ int result;
+ {
+ Mixer mix(numWaveTracksSelected, // int numInputTracks
+ waveTracks, // WaveTrack **inputTracks
+ mTracks->GetTimeTrack(), // TimeTrack *timeTrack
+ 0.0, // double startTime
+ endTime, // double stopTime
+ 2, // int numOutChannels
+ 44100, // int outBufferSize
+ true, // bool outInterleaved
+ mRate, // double outRate
+ floatSample, // sampleFormat outFormat
+ true, // bool highQuality = true
+ NULL); // MixerSpec *mixerSpec = NULL
+ delete [] waveTracks;
- ASAProgress *progress = new ASAProgress;
+ ASAProgress progress;
- // There's a lot of adjusting made to incorporate the note track offset into
- // the note track while preserving the position of notes within beats and
- // measures. For debugging, you can see just the pre-scorealign note track
- // manipulation by setting SKIP_ACTUAL_SCORE_ALIGNMENT. You could then, for
- // example, save the modified note track in ".gro" form to read the details.
- //#define SKIP_ACTUAL_SCORE_ALIGNMENT 1
+ // There's a lot of adjusting made to incorporate the note track offset into
+ // the note track while preserving the position of notes within beats and
+ // measures. For debugging, you can see just the pre-scorealign note track
+ // manipulation by setting SKIP_ACTUAL_SCORE_ALIGNMENT. You could then, for
+ // example, save the modified note track in ".gro" form to read the details.
+ //#define SKIP_ACTUAL_SCORE_ALIGNMENT 1
#ifndef SKIP_ACTUAL_SCORE_ALIGNMENT
- int result = scorealign((void *) mix, &mixer_process,
- 2 /* channels */, 44100.0 /* srate */, endTime,
- alignedNoteTrack->GetSequence(), progress, params);
+ result = scorealign((void *) &mix, &mixer_process,
+ 2 /* channels */, 44100.0 /* srate */, endTime,
+ alignedNoteTrack->GetSequence(), &progress, params);
#else
- int result = SA_SUCCESS;
+ result = SA_SUCCESS;
#endif
-
- delete progress;
- delete mix;
+ }
if (result == SA_SUCCESS) {
mTracks->Replace(nt, alignedNoteTrack, true);
diff --git a/src/Mix.cpp b/src/Mix.cpp
index 93eb0aab4..4ce0cef02 100644
--- a/src/Mix.cpp
+++ b/src/Mix.cpp
@@ -161,39 +161,40 @@ bool MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
endTime = mixEndTime;
}
- Mixer *mixer = new Mixer(numWaves, waveArray,
- Mixer::WarpOptions(tracks->GetTimeTrack()),
- startTime, endTime, mono ? 1 : 2, maxBlockLen, false,
- rate, format);
+ Mixer mixer(numWaves, waveArray,
+ Mixer::WarpOptions(tracks->GetTimeTrack()),
+ startTime, endTime, mono ? 1 : 2, maxBlockLen, false,
+ rate, format);
::wxSafeYield();
- ProgressDialog *progress = new ProgressDialog(_("Mix and Render"),
- _("Mixing and rendering tracks"));
int updateResult = eProgressSuccess;
- while(updateResult == eProgressSuccess) {
- sampleCount blockLen = mixer->Process(maxBlockLen);
+ {
+ ProgressDialog progress(_("Mix and Render"),
+ _("Mixing and rendering tracks"));
- if (blockLen == 0)
- break;
+ while (updateResult == eProgressSuccess) {
+ sampleCount blockLen = mixer.Process(maxBlockLen);
- if (mono) {
- samplePtr buffer = mixer->GetBuffer();
- mixLeft->Append(buffer, format, blockLen);
+ if (blockLen == 0)
+ break;
+
+ if (mono) {
+ samplePtr buffer = mixer.GetBuffer();
+ mixLeft->Append(buffer, format, blockLen);
+ }
+ else {
+ samplePtr buffer;
+ buffer = mixer.GetBuffer(0);
+ mixLeft->Append(buffer, format, blockLen);
+ buffer = mixer.GetBuffer(1);
+ mixRight->Append(buffer, format, blockLen);
+ }
+
+ updateResult = progress.Update(mixer.MixGetCurrentTime() - startTime, endTime - startTime);
}
- else {
- samplePtr buffer;
- buffer = mixer->GetBuffer(0);
- mixLeft->Append(buffer, format, blockLen);
- buffer = mixer->GetBuffer(1);
- mixRight->Append(buffer, format, blockLen);
- }
-
- updateResult = progress->Update(mixer->MixGetCurrentTime() - startTime, endTime - startTime);
}
- delete progress;
-
mixLeft->Flush();
if (!mono)
mixRight->Flush();
@@ -222,7 +223,6 @@ bool MixAndRender(TrackList *tracks, TrackFactory *trackFactory,
}
delete[] waveArray;
- delete mixer;
return (updateResult == eProgressSuccess || updateResult == eProgressStopped);
}
diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp
index 3c9409701..009e923d8 100644
--- a/src/MixerBoard.cpp
+++ b/src/MixerBoard.cpp
@@ -1765,15 +1765,15 @@ MixerBoardFrame::MixerBoardFrame(AudacityProject* parent)
mMixerBoard->UpdateTrackClusters();
// loads either the XPM or the windows resource, depending on the platform
- #if !defined(__WXMAC__) && !defined(__WXX11__)
- wxIcon *ic;
- #ifdef __WXMSW__
- ic = new wxIcon(wxICON(AudacityLogo));
- #else
- ic = new wxIcon(wxICON(AudacityLogo48x48));
- #endif
- SetIcon(*ic);
- delete ic;
+#if !defined(__WXMAC__) && !defined(__WXX11__)
+ {
+#ifdef __WXMSW__
+ wxIcon ic{ wxICON(AudacityLogo) };
+#else
+ wxIcon ic{wxICON(AudacityLogo48x48)};
+#endif
+ SetIcon(ic);
+ }
#endif
}
diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp
index 52ea191d1..1c4b38cd2 100644
--- a/src/PluginManager.cpp
+++ b/src/PluginManager.cpp
@@ -969,58 +969,58 @@ void PluginRegistrationDialog::OnOK(wxCommandEvent & WXUNUSED(evt))
// Make sure the progress dialog is deleted before we call EndModal() or
// we will leave the project window in an unusable state on OSX.
// See bug #1192.
- ProgressDialog *progress = new ProgressDialog(GetTitle(), msg, pdlgHideStopButton);
- progress->CenterOnParent();
-
- int i = 0;
- for (ItemDataMap::iterator iter = mItems.begin(); iter != mItems.end(); ++iter)
{
- ItemData & item = iter->second;
- wxString path = item.path;
+ ProgressDialog progress(GetTitle(), msg, pdlgHideStopButton);
+ progress.CenterOnParent();
- if (item.state == STATE_Enabled && item.plugs[0]->GetPluginType() == PluginTypeStub)
+ int i = 0;
+ for (ItemDataMap::iterator iter = mItems.begin(); iter != mItems.end(); ++iter)
{
- last3 = last3.AfterFirst(wxT('\n')) + item.path + wxT("\n");
- int status = progress->Update(++i, enableCount, wxString::Format(_("Enabling effect:\n\n%s"), last3.c_str()));
- if (!status)
- {
- break;
- }
+ ItemData & item = iter->second;
+ wxString path = item.path;
- // Try to register the plugin via each provider until one succeeds
- for (size_t j = 0, cnt = item.plugs.GetCount(); j < cnt; j++)
+ if (item.state == STATE_Enabled && item.plugs[0]->GetPluginType() == PluginTypeStub)
{
- if (mm.RegisterPlugin(item.plugs[j]->GetProviderID(), path))
+ last3 = last3.AfterFirst(wxT('\n')) + item.path + wxT("\n");
+ int status = progress.Update(++i, enableCount, wxString::Format(_("Enabling effect:\n\n%s"), last3.c_str()));
+ if (!status)
{
- for (size_t j = 0, cnt = item.plugs.GetCount(); j < cnt; j++)
- {
- pm.mPlugins.erase(item.plugs[j]->GetProviderID() + wxT("_") + path);
- }
break;
}
+
+ // Try to register the plugin via each provider until one succeeds
+ for (size_t j = 0, cnt = item.plugs.GetCount(); j < cnt; j++)
+ {
+ if (mm.RegisterPlugin(item.plugs[j]->GetProviderID(), path))
+ {
+ for (size_t j = 0, cnt = item.plugs.GetCount(); j < cnt; j++)
+ {
+ pm.mPlugins.erase(item.plugs[j]->GetProviderID() + wxT("_") + path);
+ }
+ break;
+ }
+ }
+ }
+ else if (item.state == STATE_New)
+ {
+ for (size_t j = 0, cnt = item.plugs.GetCount(); j < cnt; j++)
+ {
+ item.plugs[j]->SetValid(false);
+ }
+ }
+ else if (item.state != STATE_New)
+ {
+ for (size_t j = 0, cnt = item.plugs.GetCount(); j < cnt; j++)
+ {
+ item.plugs[j]->SetEnabled(item.state == STATE_Enabled);
+ item.plugs[j]->SetValid(item.valid);
+ }
}
}
- else if (item.state == STATE_New)
- {
- for (size_t j = 0, cnt = item.plugs.GetCount(); j < cnt; j++)
- {
- item.plugs[j]->SetValid(false);
- }
- }
- else if (item.state != STATE_New)
- {
- for (size_t j = 0, cnt = item.plugs.GetCount(); j < cnt; j++)
- {
- item.plugs[j]->SetEnabled(item.state == STATE_Enabled);
- item.plugs[j]->SetValid(item.valid);
- }
- }
+
+ pm.Save();
}
- pm.Save();
-
- delete progress;
-
EndModal(wxID_OK);
}
diff --git a/src/Project.cpp b/src/Project.cpp
index 7725e5c04..cbf5d54d9 100644
--- a/src/Project.cpp
+++ b/src/Project.cpp
@@ -1026,17 +1026,17 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
// loads either the XPM or the windows resource, depending on the platform
#if !defined(__WXMAC__) && !defined(__WXX11__)
- wxIcon *ic;
- #if defined(__WXMSW__)
- ic = new wxIcon(wxICON(AudacityLogo));
- #elif defined(__WXGTK__)
- ic = new wxIcon(wxICON(AudacityLogoAlpha));
- #else
- ic = new wxIcon();
+ {
+#if defined(__WXMSW__)
+ wxIcon ic{ wxICON(AudacityLogo) };
+#elif defined(__WXGTK__)
+ wxIcon ic{wxICON(AudacityLogoAlpha)};
+#else
+ wxIcon ic{};
ic.CopyFromBitmap(theTheme.Bitmap(bmpAudacityLogo48x48));
- #endif
- SetIcon(*ic);
- delete ic;
+#endif
+ SetIcon(ic);
+ }
#endif
mIconized = false;
@@ -1473,9 +1473,8 @@ void AudacityProject::FinishAutoScroll()
// Call our Scroll method which updates our ViewInfo variables
// to reflect the positions of the scrollbars
- wxScrollEvent *dummy = new wxScrollEvent();
- OnScroll(*dummy);
- delete dummy;
+ wxScrollEvent dummy;
+ OnScroll(dummy);
mAutoScrolling = false;
}
@@ -1590,9 +1589,8 @@ void AudacityProject::TP_ScrollWindow(double scrollto)
// Call our Scroll method which updates our ViewInfo variables
// to reflect the positions of the scrollbars
- wxScrollEvent *dummy = new wxScrollEvent();
- OnScroll(*dummy);
- delete dummy;
+ wxScrollEvent dummy;
+ OnScroll(dummy);
}
//
@@ -2643,25 +2641,24 @@ void AudacityProject::OpenFile(wxString fileName, bool addtohistory)
// for a long time searching for line breaks. So, we look for our
// signature at the beginning of the file first:
- wxFFile *ff = new wxFFile(fileName, wxT("rb"));
- if (!ff->IsOpened()) {
- wxMessageBox(_("Could not open file: ") + fileName,
- _("Error opening file"),
- wxOK | wxCENTRE, this);
- }
char buf[16];
- int numRead = ff->Read(buf, 15);
- if (numRead != 15) {
- wxMessageBox(wxString::Format(_("File may be invalid or corrupted: \n%s"),
- (const wxChar*)fileName), _("Error Opening File or Project"),
- wxOK | wxCENTRE, this);
- ff->Close();
- delete ff;
- return;
+ {
+ wxFFile ff(fileName, wxT("rb"));
+ if (!ff.IsOpened()) {
+ wxMessageBox(_("Could not open file: ") + fileName,
+ _("Error opening file"),
+ wxOK | wxCENTRE, this);
+ }
+ int numRead = ff.Read(buf, 15);
+ if (numRead != 15) {
+ wxMessageBox(wxString::Format(_("File may be invalid or corrupted: \n%s"),
+ (const wxChar*)fileName), _("Error Opening File or Project"),
+ wxOK | wxCENTRE, this);
+ ff.Close();
+ return;
+ }
+ buf[15] = 0;
}
- buf[15] = 0;
- ff->Close();
- delete ff;
wxString temp = LAT1CTOWX(buf);
@@ -3617,21 +3614,19 @@ bool AudacityProject::Save(bool overwrite /* = true */ ,
WaveTrack* pWaveTrack;
TrackListOfKindIterator iter(Track::Wave, mTracks);
unsigned int numWaveTracks = 0;
- TrackList* pSavedTrackList = new TrackList();
+
+ TrackList pSavedTrackList(true);
for (pTrack = iter.First(); pTrack != NULL; pTrack = iter.Next())
{
numWaveTracks++;
pWaveTrack = (WaveTrack*)pTrack;
pSavedTrack = mTrackFactory->DuplicateWaveTrack(*pWaveTrack);
- pSavedTrackList->Add(pSavedTrack);
+ pSavedTrackList.Add(pSavedTrack);
}
if (numWaveTracks == 0)
- {
// Nothing to save compressed => success. Delete the copies and go.
- delete pSavedTrackList;
return true;
- }
// Okay, now some bold state-faking to default values.
for (pTrack = iter.First(); pTrack != NULL; pTrack = iter.Next())
@@ -3683,7 +3678,7 @@ bool AudacityProject::Save(bool overwrite /* = true */ ,
}
// Restore the saved track states and clean up.
- TrackListIterator savedTrackIter(pSavedTrackList);
+ TrackListIterator savedTrackIter(&pSavedTrackList);
for (pTrack = iter.First(), pSavedTrack = savedTrackIter.First();
((pTrack != NULL) && (pSavedTrack != NULL));
pTrack = iter.Next(), pSavedTrack = savedTrackIter.Next())
@@ -3697,9 +3692,6 @@ bool AudacityProject::Save(bool overwrite /* = true */ ,
pWaveTrack->SetPan(((WaveTrack*)pSavedTrack)->GetPan());
}
- pSavedTrackList->Clear(true);
- delete pSavedTrackList;
-
return bSuccess;
}
#endif
diff --git a/src/TrackArtist.cpp b/src/TrackArtist.cpp
index de108303e..2defc4b98 100644
--- a/src/TrackArtist.cpp
+++ b/src/TrackArtist.cpp
@@ -2162,10 +2162,10 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
// and then paint this directly to our offscreen
// bitmap. Note that this could be optimized even
// more, but for now this is not bad. -dmazzoni
- wxImage *image = new wxImage((int)mid.width, (int)mid.height);
- if (!image)
+ wxImage image((int)mid.width, (int)mid.height);
+ if (!image.IsOk())
return;
- unsigned char *data = image->GetData();
+ unsigned char *data = image.GetData();
const int half = settings.GetFFTLength() / 2;
const double binUnit = rate / (2 * half);
@@ -2471,7 +2471,7 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
} // each yy
} // each xx
- wxBitmap converted = wxBitmap(*image);
+ wxBitmap converted = wxBitmap(image);
wxMemoryDC memDC;
@@ -2479,7 +2479,6 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache,
dc.Blit(mid.x, mid.y, mid.width, mid.height, &memDC, 0, 0, wxCOPY, FALSE);
- delete image;
#ifdef EXPERIMENTAL_FFT_Y_GRID
delete[] yGrid;
#endif //EXPERIMENTAL_FFT_Y_GRID
diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp
index d99808622..91ca75e21 100644
--- a/src/TrackPanel.cpp
+++ b/src/TrackPanel.cpp
@@ -1430,53 +1430,52 @@ void TrackPanel::OnPaint(wxPaintEvent & /* event */)
wxStopWatch sw;
#endif
- // Construct the paint DC on the heap so that it may be deleted
- // early
- wxPaintDC *dc = new wxPaintDC(this);
-
- // Retrieve the damage rectangle
- wxRect box = GetUpdateRegion().GetBox();
-
- // Recreate the backing bitmap if we have a full refresh
- // (See TrackPanel::Refresh())
- if (mRefreshBacking || (box == GetRect()))
{
- // Reset (should a mutex be used???)
- mRefreshBacking = false;
+ wxPaintDC dc(this);
- if (mResizeBacking)
+ // Retrieve the damage rectangle
+ wxRect box = GetUpdateRegion().GetBox();
+
+ // Recreate the backing bitmap if we have a full refresh
+ // (See TrackPanel::Refresh())
+ if (mRefreshBacking || (box == GetRect()))
{
- // Reset
- mResizeBacking = false;
+ // Reset (should a mutex be used???)
+ mRefreshBacking = false;
- // Delete the backing bitmap
- if (mBacking)
+ if (mResizeBacking)
{
- mBackingDC.SelectObject(wxNullBitmap);
- delete mBacking;
- mBacking = NULL;
+ // Reset
+ mResizeBacking = false;
+
+ // Delete the backing bitmap
+ if (mBacking)
+ {
+ mBackingDC.SelectObject(wxNullBitmap);
+ delete mBacking;
+ mBacking = NULL;
+ }
+
+ wxSize sz = GetClientSize();
+ mBacking = new wxBitmap();
+ mBacking->Create(sz.x, sz.y); //, *dc);
+ mBackingDC.SelectObject(*mBacking);
}
- wxSize sz = GetClientSize();
- mBacking = new wxBitmap();
- mBacking->Create(sz.x, sz.y); //, *dc);
- mBackingDC.SelectObject(*mBacking);
+ // Redraw the backing bitmap
+ DrawTracks(&mBackingDC);
+
+ // Copy it to the display
+ dc.Blit(0, 0, mBacking->GetWidth(), mBacking->GetHeight(), &mBackingDC, 0, 0);
+ }
+ else
+ {
+ // Copy full, possibly clipped, damage rectangle
+ dc.Blit(box.x, box.y, box.width, box.height, &mBackingDC, box.x, box.y);
}
- // Redraw the backing bitmap
- DrawTracks(&mBackingDC);
-
- // Copy it to the display
- dc->Blit(0, 0, mBacking->GetWidth(), mBacking->GetHeight(), &mBackingDC, 0, 0);
+ // Done with the clipped DC
}
- else
- {
- // Copy full, possibly clipped, damage rectangle
- dc->Blit(box.x, box.y, box.width, box.height, &mBackingDC, box.x, box.y);
- }
-
- // Done with the clipped DC
- delete dc;
// Drawing now goes directly to the client area. It can't use the paint DC
// becuase the paint DC might be clipped and DrawOverlays() may need to draw
diff --git a/src/UndoManager.cpp b/src/UndoManager.cpp
index bebce6bfa..36a68e33c 100644
--- a/src/UndoManager.cpp
+++ b/src/UndoManager.cpp
@@ -57,15 +57,14 @@ void UndoManager::CalculateSpaceUsage()
space.Clear();
space.Add(0, stack.GetCount());
- Set *prev = new Set;
- Set *cur = new Set;
+ Set s1, s2;
+ Set *prev = &s1;
+ Set *cur = &s2;
for (size_t i = 0, cnt = stack.GetCount(); i < cnt; i++)
{
// Swap map pointers
- Set *swap = prev;
- prev = cur;
- cur = swap;
+ std::swap(cur, prev);
// And clean out the NEW current map
cur->clear();
@@ -102,8 +101,6 @@ void UndoManager::CalculateSpaceUsage()
}
}
- delete cur;
- delete prev;
TIMER_STOP( space_calc );
}
diff --git a/src/VoiceKey.cpp b/src/VoiceKey.cpp
index d22cb9768..47d7649bc 100644
--- a/src/VoiceKey.cpp
+++ b/src/VoiceKey.cpp
@@ -827,13 +827,12 @@ void VoiceKey::CalibrateNoise(WaveTrack & t, sampleCount start, sampleCount len)
/* i18n-hint: %1.4f is replaced by a number. sd stands for 'Standard Deviations'*/
text += wxString::Format(_("Energy -- mean: %1.4f sd: (%1.4f)\n"),mEnergyMean,mEnergySD);
text+= wxString::Format(_("Sign Changes -- mean: %1.4f sd: (%1.4f)\n"),mSignChangesMean,mSignChangesSD);
- text+= wxString::Format(_("Direction Changes -- mean: %1.4f sd: (%1.4f)\n"),mDirectionChangesMean,mDirectionChangesSD);
- wxMessageDialog * stats = new wxMessageDialog(NULL, text,
- wxT("Calibration Complete"),
- wxOK | wxICON_INFORMATION,
- wxPoint(-1,-1));
- stats->ShowModal();
- delete stats;
+ text += wxString::Format(_("Direction Changes -- mean: %1.4f sd: (%1.4f)\n"), mDirectionChangesMean, mDirectionChangesSD);
+ wxMessageDialog{ NULL, text,
+ wxT("Calibration Complete"),
+ wxOK | wxICON_INFORMATION,
+ wxPoint(-1, -1) }
+ .ShowModal();
AdjustThreshold(mThresholdAdjustment);
}
diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp
index 18099ba90..6e0b17c0b 100644
--- a/src/WaveClip.cpp
+++ b/src/WaveClip.cpp
@@ -1731,7 +1731,7 @@ bool WaveClip::Resample(int rate, ProgressDialog *progress)
return true; // Nothing to do
double factor = (double)rate / (double)mRate;
- ::Resample* resample = new ::Resample(true, factor, factor); // constant rate resampling
+ ::Resample resample(true, factor, factor); // constant rate resampling
int bufsize = 65536;
float* inBuffer = new float[bufsize];
@@ -1764,7 +1764,7 @@ bool WaveClip::Resample(int rate, ProgressDialog *progress)
}
int inBufferUsed = 0;
- outGenerated = resample->Process(factor, inBuffer, inLen, isLast,
+ outGenerated = resample.Process(factor, inBuffer, inLen, isLast,
&inBufferUsed, outBuffer, bufsize);
pos += inBufferUsed;
@@ -1795,7 +1795,6 @@ bool WaveClip::Resample(int rate, ProgressDialog *progress)
delete[] inBuffer;
delete[] outBuffer;
- delete resample;
if (error)
{
diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp
index 1029940d6..60e97d581 100644
--- a/src/WaveTrack.cpp
+++ b/src/WaveTrack.cpp
@@ -826,11 +826,12 @@ bool WaveTrack::ClearAndPaste(double t0, // Start of time to clear
}
// If provided time warper was NULL, use a default one that does nothing
+ IdentityTimeWarper localWarper;
TimeWarper *warper = NULL;
if (effectWarper != NULL) {
warper = effectWarper;
} else {
- warper = new IdentityTimeWarper();
+ warper = &localWarper;
}
// Align to a sample
@@ -974,10 +975,6 @@ bool WaveTrack::ClearAndPaste(double t0, // Start of time to clear
for (int ii = cuts.GetCount(); ii--;)
delete cuts[ii];
- // If we created a default time warper, we need to DELETE it
- if (effectWarper == NULL)
- delete warper;
-
return true;
}
@@ -1645,9 +1642,7 @@ sampleCount WaveTrack::GetMaxBlockSize() const
{
// We really need the maximum block size, so create a
// temporary sequence to get it.
- Sequence *tempseq = new Sequence(mDirManager, mFormat);
- maxblocksize = tempseq->GetMaxBlockSize();
- delete tempseq;
+ maxblocksize = Sequence{ mDirManager, mFormat }.GetMaxBlockSize();
}
wxASSERT(maxblocksize > 0);
diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp
index 631fd07af..c3f085b06 100644
--- a/src/effects/Contrast.cpp
+++ b/src/effects/Contrast.cpp
@@ -476,9 +476,7 @@ void ContrastDialog::OnExport(wxCommandEvent & WXUNUSED(event))
wxTextFile f(fName);
#ifdef __WXMAC__
- wxFile *temp = new wxFile();
- temp->Create(fName);
- delete temp;
+ wxFile{}.Create(fName);
#else
f.Create();
#endif
diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp
index 264d6cef5..774bd52f2 100644
--- a/src/effects/Effect.cpp
+++ b/src/effects/Effect.cpp
@@ -1154,6 +1154,16 @@ void Effect::SetBatchProcessing(bool start)
}
}
+namespace {
+ struct SetProgress {
+ SetProgress(ProgressDialog *& mProgress_, ProgressDialog *progress)
+ : mProgress(mProgress_)
+ { mProgress = progress; }
+ ~SetProgress() { mProgress = nullptr; }
+ ProgressDialog *& mProgress;
+ };
+}
+
bool Effect::DoEffect(wxWindow *parent,
double projectRate,
TrackList *list,
@@ -1230,12 +1240,11 @@ bool Effect::DoEffect(wxWindow *parent,
bool skipFlag = CheckWhetherSkipEffect();
if (skipFlag == false)
{
- mProgress = new ProgressDialog(GetName(),
- wxString::Format(_("Applying %s..."), GetName().c_str()),
- pdlgHideStopButton);
+ ProgressDialog progress(GetName(),
+ wxString::Format(_("Applying %s..."), GetName().c_str()),
+ pdlgHideStopButton);
+ SetProgress sp(mProgress, &progress);
returnVal = Process();
- delete mProgress;
- mProgress = NULL;
}
End();
@@ -1870,22 +1879,20 @@ bool Effect::ProcessTrack(int count,
if (isGenerator)
{
AudacityProject *p = GetActiveProject();
- StepTimeWarper *warper = new StepTimeWarper(mT0 + genLength, genLength - (mT1 - mT0));
+ StepTimeWarper warper(mT0 + genLength, genLength - (mT1 - mT0));
// Transfer the data from the temporary tracks to the actual ones
genLeft->Flush();
// mT1 gives us the NEW selection. We want to replace up to GetSel1().
- left->ClearAndPaste(mT0, p->GetSel1(), genLeft, true, true, warper);
+ left->ClearAndPaste(mT0, p->GetSel1(), genLeft, true, true, &warper);
delete genLeft;
if (genRight)
{
genRight->Flush();
- right->ClearAndPaste(mT0, mT1, genRight, true, true, warper);
+ right->ClearAndPaste(mT0, mT1, genRight, true, true, &warper);
delete genRight;
}
-
- delete warper;
}
// Allow the plugin to cleanup
@@ -2529,14 +2536,13 @@ void Effect::Preview(bool dryOnly)
// Apply effect
if (!dryOnly) {
- mProgress = new ProgressDialog(GetName(),
- _("Preparing preview"),
- pdlgHideCancelButton); // Have only "Stop" button.
+ ProgressDialog progress(GetName(),
+ _("Preparing preview"),
+ pdlgHideCancelButton); // Have only "Stop" button.
+ SetProgress sp(mProgress, &progress);
mIsPreview = true;
success = Process();
mIsPreview = false;
- delete mProgress;
- mProgress = NULL;
}
if (success)
@@ -2570,16 +2576,16 @@ void Effect::Preview(bool dryOnly)
// The progress dialog must be deleted before stopping the stream
// to allow events to flow to the app during StopStream processing.
// The progress dialog blocks these events.
- ProgressDialog *progress =
- new ProgressDialog(GetName(), _("Previewing"), pdlgHideCancelButton);
+ {
+ ProgressDialog progress
+ (GetName(), _("Previewing"), pdlgHideCancelButton);
- while (gAudioIO->IsStreamActive(token) && previewing == eProgressSuccess) {
- ::wxMilliSleep(100);
- previewing = progress->Update(gAudioIO->GetStreamTime() - mT0, t1 - mT0);
+ while (gAudioIO->IsStreamActive(token) && previewing == eProgressSuccess) {
+ ::wxMilliSleep(100);
+ previewing = progress.Update(gAudioIO->GetStreamTime() - mT0, t1 - mT0);
+ }
}
- delete progress;
-
gAudioIO->StopStream();
while (gAudioIO->IsBusy()) {
@@ -3207,14 +3213,14 @@ void EffectUIHost::OnDebug(wxCommandEvent & evt)
void EffectUIHost::OnMenu(wxCommandEvent & WXUNUSED(evt))
{
- wxMenu *menu = new wxMenu();
+ wxMenu menu;
wxMenu *sub;
LoadUserPresets();
if (mUserPresets.GetCount() == 0)
{
- menu->Append(kUserPresetsDummyID, _("User Presets"))->Enable(false);
+ menu.Append(kUserPresetsDummyID, _("User Presets"))->Enable(false);
}
else
{
@@ -3223,14 +3229,14 @@ void EffectUIHost::OnMenu(wxCommandEvent & WXUNUSED(evt))
{
sub->Append(kUserPresetsID + i, mUserPresets[i]);
}
- menu->Append(0, _("User Presets"), sub);
+ menu.Append(0, _("User Presets"), sub);
}
- menu->Append(kSaveAsID, _("Save Preset..."));
+ menu.Append(kSaveAsID, _("Save Preset..."));
if (mUserPresets.GetCount() == 0)
{
- menu->Append(kDeletePresetDummyID, _("Delete Preset"))->Enable(false);
+ menu.Append(kDeletePresetDummyID, _("Delete Preset"))->Enable(false);
}
else
{
@@ -3239,10 +3245,10 @@ void EffectUIHost::OnMenu(wxCommandEvent & WXUNUSED(evt))
{
sub->Append(kDeletePresetID + i, mUserPresets[i]);
}
- menu->Append(0, _("Delete Preset"), sub);
+ menu.Append(0, _("Delete Preset"), sub);
}
- menu->AppendSeparator();
+ menu.AppendSeparator();
wxArrayString factory = mEffect->GetFactoryPresets();
@@ -3262,14 +3268,14 @@ void EffectUIHost::OnMenu(wxCommandEvent & WXUNUSED(evt))
sub->Append(kFactoryPresetsID + i, label);
}
}
- menu->Append(0, _("Factory Presets"), sub);
+ menu.Append(0, _("Factory Presets"), sub);
- menu->AppendSeparator();
- menu->Append(kImportID, _("Import..."))->Enable(mClient->CanExportPresets());
- menu->Append(kExportID, _("Export..."))->Enable(mClient->CanExportPresets());
- menu->AppendSeparator();
- menu->Append(kOptionsID, _("Options..."))->Enable(mClient->HasOptions());
- menu->AppendSeparator();
+ menu.AppendSeparator();
+ menu.Append(kImportID, _("Import..."))->Enable(mClient->CanExportPresets());
+ menu.Append(kExportID, _("Export..."))->Enable(mClient->CanExportPresets());
+ menu.AppendSeparator();
+ menu.Append(kOptionsID, _("Options..."))->Enable(mClient->HasOptions());
+ menu.AppendSeparator();
sub = new wxMenu();
@@ -3279,13 +3285,11 @@ void EffectUIHost::OnMenu(wxCommandEvent & WXUNUSED(evt))
sub->Append(kDummyID, wxString::Format(_("Vendor: %s"), mEffect->GetVendor().c_str()));
sub->Append(kDummyID, wxString::Format(_("Description: %s"), mEffect->GetDescription().c_str()));
- menu->Append(0, _("About"), sub);
+ menu.Append(0, _("About"), sub);
wxWindow *btn = FindWindow(kMenuID);
wxRect r = btn->GetRect();
- btn->PopupMenu(menu, r.GetLeft(), r.GetBottom());
-
- delete menu;
+ btn->PopupMenu(&menu, r.GetLeft(), r.GetBottom());
}
void EffectUIHost::OnEnable(wxCommandEvent & WXUNUSED(evt))
diff --git a/src/effects/Effect.h b/src/effects/Effect.h
index d3a72bf76..75a9ddcf5 100644
--- a/src/effects/Effect.h
+++ b/src/effects/Effect.h
@@ -362,7 +362,7 @@ protected:
// may be needed by any particular subclass of Effect.
//
protected:
- ProgressDialog *mProgress;
+ ProgressDialog *mProgress; // Temporary pointer, NOT deleted in destructor.
double mProjectRate; // Sample rate of the project - NEW tracks should
// be created with this rate...
double mSampleRate;
diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp
index 1a74652a0..869cc13ec 100644
--- a/src/effects/Equalization.cpp
+++ b/src/effects/Equalization.cpp
@@ -2161,24 +2161,23 @@ void EffectEqualization::ErrMin(void)
double correction = 1.6;
bool flag;
int j=0;
- Envelope *testEnvelope;
- testEnvelope = new Envelope();
- testEnvelope->SetInterpolateDB(false);
- testEnvelope->Mirror(false);
- testEnvelope->SetRange(-120.0, 60.0);
- testEnvelope->Flatten(0.);
- testEnvelope->SetTrackLen(1.0);
- testEnvelope->CopyFrom(mLogEnvelope, 0.0, 1.0);
+ Envelope testEnvelope;
+ testEnvelope.SetInterpolateDB(false);
+ testEnvelope.Mirror(false);
+ testEnvelope.SetRange(-120.0, 60.0);
+ testEnvelope.Flatten(0.);
+ testEnvelope.SetTrackLen(1.0);
+ testEnvelope.CopyFrom(mLogEnvelope, 0.0, 1.0);
for(i=0; i < NUM_PTS; i++)
- vals[i] = testEnvelope->GetValue(mWhens[i]);
+ vals[i] = testEnvelope.GetValue(mWhens[i]);
// Do error minimisation
error = 0.;
- GraphicEQ(testEnvelope);
+ GraphicEQ(&testEnvelope);
for(i=0; i < NUM_PTS; i++) //calc initial error
{
- double err = vals[i] - testEnvelope->GetValue(mWhens[i]);
+ double err = vals[i] - testEnvelope.GetValue(mWhens[i]);
error += err*err;
}
oldError = error;
@@ -2208,11 +2207,11 @@ void EffectEqualization::ErrMin(void)
mEQVals[i] = -20.;
flag = false;
}
- GraphicEQ(testEnvelope); //calculate envelope
+ GraphicEQ(&testEnvelope); //calculate envelope
error = 0.;
for(int k=0; k < NUM_PTS; k++) //calculate error
{
- double err = vals[k] - testEnvelope->GetValue(mWhens[k]);
+ double err = vals[k] - testEnvelope.GetValue(mWhens[k]);
error += err*err;
}
}
@@ -2231,9 +2230,8 @@ void EffectEqualization::ErrMin(void)
if( error > .0025 * mBandsInUse ) // not within 0.05dB on each slider, on average
{
Select( (int) mCurves.GetCount()-1 );
- EnvelopeUpdated(testEnvelope, false);
+ EnvelopeUpdated(&testEnvelope, false);
}
- delete testEnvelope;
}
void EffectEqualization::GraphicEQ(Envelope *env)
diff --git a/src/effects/Equalization48x.cpp b/src/effects/Equalization48x.cpp
index 1d93e43e7..c65ffb0ad 100644
--- a/src/effects/Equalization48x.cpp
+++ b/src/effects/Equalization48x.cpp
@@ -332,8 +332,8 @@ bool EffectEqualization48x::TrackCompare()
wxArrayPtrVoid SecondOMap;
SecondIMap.Clear();
SecondOMap.Clear();
-
- TrackList *SecondOutputTracks = new TrackList();
+
+ TrackList SecondOutputTracks(true);
//iterate over tracks of type trackType (All types if Track::All)
TrackListOfKindIterator aIt(mEffectEqualization->mOutputTracksType, mEffectEqualization->mTracks);
@@ -345,14 +345,14 @@ bool EffectEqualization48x::TrackCompare()
(mEffectEqualization->mOutputTracksType == Track::All && aTrack->IsSyncLockSelected()))
{
Track *o = aTrack->Duplicate();
- SecondOutputTracks->Add(o);
+ SecondOutputTracks.Add(o);
SecondIMap.Add(aTrack);
SecondIMap.Add(o);
}
}
for(int i=0;i<2;i++) {
- SelectedTrackListOfKindIterator iter(Track::Wave, i?mEffectEqualization->mOutputTracks:SecondOutputTracks);
+ SelectedTrackListOfKindIterator iter(Track::Wave, i ? mEffectEqualization->mOutputTracks : &SecondOutputTracks);
i?sMathPath=sMathPath:sMathPath=0;
WaveTrack *track = (WaveTrack *) iter.First();
int count = 0;
@@ -375,7 +375,7 @@ bool EffectEqualization48x::TrackCompare()
}
}
SelectedTrackListOfKindIterator iter(Track::Wave, mEffectEqualization->mOutputTracks);
- SelectedTrackListOfKindIterator iter2(Track::Wave, SecondOutputTracks);
+ SelectedTrackListOfKindIterator iter2(Track::Wave, &SecondOutputTracks);
WaveTrack *track = (WaveTrack *) iter.First();
WaveTrack *track2 = (WaveTrack *) iter2.First();
while (track) {
@@ -393,7 +393,6 @@ bool EffectEqualization48x::TrackCompare()
track = (WaveTrack *) iter.Next();
track2 = (WaveTrack *) iter2.Next();
}
- delete SecondOutputTracks;
FreeBuffersWorkers();
mEffectEqualization->ReplaceProcessedTracks(!bBreakLoop);
return bBreakLoop;
diff --git a/src/effects/Paulstretch.cpp b/src/effects/Paulstretch.cpp
index 1144cae4d..3df9fe47e 100644
--- a/src/effects/Paulstretch.cpp
+++ b/src/effects/Paulstretch.cpp
@@ -290,11 +290,11 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun
WaveTrack * outputTrack = mFactory->NewWaveTrack(track->GetSampleFormat(),track->GetRate());
- PaulStretch *stretch=new PaulStretch(amount,stretch_buf_size,track->GetRate());
+ PaulStretch stretch(amount,stretch_buf_size,track->GetRate());
- sampleCount nget=stretch->get_nsamples_for_fill();
+ sampleCount nget=stretch.get_nsamples_for_fill();
- int bufsize=stretch->poolsize;
+ int bufsize=stretch.poolsize;
float *buffer0=new float[bufsize];
float *bufferptr0=buffer0;
sampleCount outs=0;
@@ -308,13 +308,13 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun
while (sGet((samplePtr)bufferptr0,floatSample,start+s,nget);
- stretch->process(buffer0,nget);
+ stretch.process(buffer0,nget);
if (first_time) {
- stretch->process(buffer0,0);
+ stretch.process(buffer0,0);
};
- outs+=stretch->out_bufsize;
+ outs+=stretch.out_bufsize;
s+=nget;
if (first_time){//blend the the start of the selection
@@ -322,7 +322,7 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun
first_time=false;
for (int i=0;iout_buf[i]=stretch->out_buf[i]*fi+(1.0-fi)*fade_track_smps[i];
+ stretch.out_buf[i]=stretch.out_buf[i]*fi+(1.0-fi)*fade_track_smps[i];
};
};
if (s>=len){//blend the end of the selection
@@ -330,13 +330,13 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun
for (int i=0;iout_buf[i2]=stretch->out_buf[i2]*fi+(1.0-fi)*fade_track_smps[fade_len-1-i];
+ stretch.out_buf[i2]=stretch.out_buf[i2]*fi+(1.0-fi)*fade_track_smps[fade_len-1-i];
};
};
- outputTrack->Append((samplePtr)stretch->out_buf,floatSample,stretch->out_bufsize);
+ outputTrack->Append((samplePtr)stretch.out_buf,floatSample,stretch.out_bufsize);
- nget=stretch->get_nsamples();
+ nget=stretch.get_nsamples();
if (TrackProgress(count, (s / (double) len))) {
cancelled=true;
break;
@@ -352,7 +352,6 @@ bool EffectPaulstretch::ProcessOne(WaveTrack *track,double t0,double t1,int coun
m_t1 = mT0 + outputTrack->GetEndTime();
}
- delete stretch;
delete []buffer0;
delete outputTrack;
diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp
index 23589691b..0da16c3ba 100644
--- a/src/effects/VST/VSTEffect.cpp
+++ b/src/effects/VST/VSTEffect.cpp
@@ -470,25 +470,24 @@ bool VSTEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxStrin
wxString cmd;
cmd.Printf(wxT("\"%s\" %s \"%s;%s\""), cmdpath.c_str(), VSTCMDKEY, path.c_str(), effectID.c_str());
- VSTSubProcess *proc = new VSTSubProcess();
+ VSTSubProcess proc;
try
{
int flags = wxEXEC_SYNC | wxEXEC_NODISABLE;
#if defined(__WXMSW__)
flags += wxEXEC_NOHIDE;
#endif
- wxExecute(cmd, flags, proc);
+ wxExecute(cmd, flags, &proc);
}
catch (...)
{
wxLogMessage(_("VST plugin registration failed for %s\n"), path.c_str());
- delete proc;
return false;
}
wxString output;
wxStringOutputStream ss(&output);
- proc->GetInputStream()->Read(ss);
+ proc.GetInputStream()->Read(ss);
int keycount = 0;
bool haveBegin = false;
@@ -519,7 +518,7 @@ bool VSTEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxStrin
if (idCnt > 3)
{
progress = new wxProgressDialog(_("Scanning Shell VST"),
- wxString::Format(_("Registering %d of %d: %-64.64s"), 0, idCnt, proc->GetName().c_str()),
+ wxString::Format(_("Registering %d of %d: %-64.64s"), 0, idCnt, proc.GetName().c_str()),
idCnt,
NULL,
wxPD_APP_MODAL |
@@ -538,44 +537,44 @@ bool VSTEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxStrin
break;
case kKeyName:
- proc->mName = val;
+ proc.mName = val;
keycount++;
break;
case kKeyPath:
- proc->mPath = val;
+ proc.mPath = val;
keycount++;
break;
case kKeyVendor:
- proc->mVendor = val;
+ proc.mVendor = val;
keycount++;
break;
case kKeyVersion:
- proc->mVersion = val;
+ proc.mVersion = val;
keycount++;
break;
case kKeyDescription:
- proc->mDescription = val;
+ proc.mDescription = val;
keycount++;
break;
case kKeyEffectType:
long type;
val.ToLong(&type);
- proc->mType = (EffectType) type;
+ proc.mType = (EffectType) type;
keycount++;
break;
case kKeyInteractive:
- proc->mInteractive = val.IsSameAs(wxT("1"));
+ proc.mInteractive = val.IsSameAs(wxT("1"));
keycount++;
break;
case kKeyAutomatable:
- proc->mAutomatable = val.IsSameAs(wxT("1"));
+ proc.mAutomatable = val.IsSameAs(wxT("1"));
keycount++;
break;
@@ -593,13 +592,13 @@ bool VSTEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxStrin
{
idNdx++;
cont = progress->Update(idNdx,
- wxString::Format(_("Registering %d of %d: %-64.64s"), idNdx, idCnt, proc->GetName().c_str()));
+ wxString::Format(_("Registering %d of %d: %-64.64s"), idNdx, idCnt, proc.GetName().c_str()));
}
if (!skip && cont)
{
valid = true;
- pm.RegisterPlugin(this, proc);
+ pm.RegisterPlugin(this, &proc);
}
}
break;
@@ -610,8 +609,6 @@ bool VSTEffectsModule::RegisterPlugin(PluginManagerInterface & pm, const wxStrin
break;
}
}
-
- delete proc;
}
if (progress)
@@ -656,47 +653,42 @@ void VSTEffectsModule::DeleteInstance(IdentInterface *instance)
// Called from reinvokation of Audacity or DLL to check in a separate process
void VSTEffectsModule::Check(const wxChar *path)
{
- VSTEffect *effect = new VSTEffect(path);
- if (effect)
+ VSTEffect effect(path);
+ if (effect.SetHost(NULL))
{
- if (effect->SetHost(NULL))
+ wxArrayInt effectIDs = effect.GetEffectIDs();
+ wxString out;
+
+ if (effectIDs.GetCount() > 0)
{
- wxArrayInt effectIDs = effect->GetEffectIDs();
- wxString out;
+ wxString subids;
- if (effectIDs.GetCount() > 0)
+ for (size_t i = 0, cnt = effectIDs.GetCount(); i < cnt; i++)
{
- wxString subids;
-
- for (size_t i = 0, cnt = effectIDs.GetCount(); i < cnt; i++)
- {
- subids += wxString::Format(wxT("%d;"), effectIDs[i]);
- }
-
- out = wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeySubIDs, subids.RemoveLast().c_str());
- }
- else
- {
- out += wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeyBegin, wxEmptyString);
- out += wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeyPath, effect->GetPath().c_str());
- out += wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeyName, effect->GetName().c_str());
- out += wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeyVendor, effect->GetVendor().c_str());
- out += wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeyVersion, effect->GetVersion().c_str());
- out += wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeyDescription, effect->GetDescription().c_str());
- out += wxString::Format(wxT("%s%d=%d\n"), OUTPUTKEY, kKeyEffectType, effect->GetType());
- out += wxString::Format(wxT("%s%d=%d\n"), OUTPUTKEY, kKeyInteractive, effect->IsInteractive());
- out += wxString::Format(wxT("%s%d=%d\n"), OUTPUTKEY, kKeyAutomatable, effect->SupportsAutomation());
- out += wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeyEnd, wxEmptyString);
+ subids += wxString::Format(wxT("%d;"), effectIDs[i]);
}
- // We want to output info in one chunk to prevent output
- // from the effect intermixing with the info
- const wxCharBuffer buf = out.ToUTF8();
- fwrite(buf, 1, strlen(buf), stdout);
- fflush(stdout);
+ out = wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeySubIDs, subids.RemoveLast().c_str());
+ }
+ else
+ {
+ out += wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeyBegin, wxEmptyString);
+ out += wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeyPath, effect.GetPath().c_str());
+ out += wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeyName, effect.GetName().c_str());
+ out += wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeyVendor, effect.GetVendor().c_str());
+ out += wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeyVersion, effect.GetVersion().c_str());
+ out += wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeyDescription, effect.GetDescription().c_str());
+ out += wxString::Format(wxT("%s%d=%d\n"), OUTPUTKEY, kKeyEffectType, effect.GetType());
+ out += wxString::Format(wxT("%s%d=%d\n"), OUTPUTKEY, kKeyInteractive, effect.IsInteractive());
+ out += wxString::Format(wxT("%s%d=%d\n"), OUTPUTKEY, kKeyAutomatable, effect.SupportsAutomation());
+ out += wxString::Format(wxT("%s%d=%s\n"), OUTPUTKEY, kKeyEnd, wxEmptyString);
}
- delete effect;
+ // We want to output info in one chunk to prevent output
+ // from the effect intermixing with the info
+ const wxCharBuffer buf = out.ToUTF8();
+ fwrite(buf, 1, strlen(buf), stdout);
+ fflush(stdout);
}
}
diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp
index 8fdb4641a..e75d1aa91 100644
--- a/src/export/ExportCL.cpp
+++ b/src/export/ExportCL.cpp
@@ -440,59 +440,59 @@ int ExportCL::Export(AudacityProject *project,
samplePtr mixed = NULL;
int updateResult = eProgressSuccess;
- // Prepare the progress display
- ProgressDialog *progress = new ProgressDialog(_("Export"),
- selectionOnly ?
- _("Exporting the selected audio using command-line encoder") :
- _("Exporting the entire project using command-line encoder"));
+ {
+ // Prepare the progress display
+ ProgressDialog progress(_("Export"),
+ selectionOnly ?
+ _("Exporting the selected audio using command-line encoder") :
+ _("Exporting the entire project using command-line encoder"));
- // Start piping the mixed data to the command
- while (updateResult == eProgressSuccess && process.IsActive() && os->IsOk()) {
- // Capture any stdout and stderr from the command
- Drain(process.GetInputStream(), &output);
- Drain(process.GetErrorStream(), &output);
+ // Start piping the mixed data to the command
+ while (updateResult == eProgressSuccess && process.IsActive() && os->IsOk()) {
+ // Capture any stdout and stderr from the command
+ Drain(process.GetInputStream(), &output);
+ Drain(process.GetErrorStream(), &output);
- // Need to mix another block
- if (numBytes == 0) {
- sampleCount numSamples = mixer->Process(maxBlockLen);
- if (numSamples == 0) {
- break;
- }
+ // Need to mix another block
+ if (numBytes == 0) {
+ sampleCount numSamples = mixer->Process(maxBlockLen);
+ if (numSamples == 0) {
+ break;
+ }
- mixed = mixer->GetBuffer();
- numBytes = numSamples * channels;
+ mixed = mixer->GetBuffer();
+ numBytes = numSamples * channels;
- // Byte-swapping is neccesary on big-endian machines, since
- // WAV files are little-endian
+ // Byte-swapping is neccesary on big-endian machines, since
+ // WAV files are little-endian
#if wxBYTE_ORDER == wxBIG_ENDIAN
- wxUint16 *buffer = (wxUint16 *) mixed;
- for (int i = 0; i < numBytes; i++) {
- buffer[i] = wxUINT16_SWAP_ON_BE(buffer[i]);
- }
+ wxUint16 *buffer = (wxUint16 *) mixed;
+ for (int i = 0; i < numBytes; i++) {
+ buffer[i] = wxUINT16_SWAP_ON_BE(buffer[i]);
+ }
#endif
- numBytes *= SAMPLE_SIZE(int16Sample);
- }
-
- // Don't write too much at once...pipes may not be able to handle it
- size_t bytes = wxMin(numBytes, 4096);
- numBytes -= bytes;
-
- while (bytes > 0) {
- os->Write(mixed, bytes);
- if (!os->IsOk()) {
- break;
+ numBytes *= SAMPLE_SIZE(int16Sample);
}
- bytes -= os->LastWrite();
- mixed += os->LastWrite();
+
+ // Don't write too much at once...pipes may not be able to handle it
+ size_t bytes = wxMin(numBytes, 4096);
+ numBytes -= bytes;
+
+ while (bytes > 0) {
+ os->Write(mixed, bytes);
+ if (!os->IsOk()) {
+ break;
+ }
+ bytes -= os->LastWrite();
+ mixed += os->LastWrite();
+ }
+
+ // Update the progress display
+ updateResult = progress.Update(mixer->MixGetCurrentTime() - t0, t1 - t0);
}
-
- // Update the progress display
- updateResult = progress->Update(mixer->MixGetCurrentTime()-t0, t1-t0);
+ // Done with the progress display
}
- // Done with the progress display
- delete progress;
-
// Should make the process die
process.CloseOutput();
diff --git a/src/export/ExportFFmpeg.cpp b/src/export/ExportFFmpeg.cpp
index 351772d0e..6913de72e 100644
--- a/src/export/ExportFFmpeg.cpp
+++ b/src/export/ExportFFmpeg.cpp
@@ -831,30 +831,29 @@ int ExportFFmpeg::Export(AudacityProject *project,
t0, t1,
channels, pcmBufferSize, true,
mSampleRate, int16Sample, true, mixerSpec);
- delete [] waveTracks;
-
- ProgressDialog *progress = new ProgressDialog(wxFileName(fName).GetName(),
- selectionOnly ?
- wxString::Format(_("Exporting selected audio as %s"), ExportFFmpegOptions::fmts[mSubFormat].description) :
- wxString::Format(_("Exporting entire file as %s"), ExportFFmpegOptions::fmts[mSubFormat].description));
+ delete[] waveTracks;
int updateResult = eProgressSuccess;
+ {
+ ProgressDialog progress(wxFileName(fName).GetName(),
+ selectionOnly ?
+ wxString::Format(_("Exporting selected audio as %s"), ExportFFmpegOptions::fmts[mSubFormat].description) :
+ wxString::Format(_("Exporting entire file as %s"), ExportFFmpegOptions::fmts[mSubFormat].description));
- while(updateResult == eProgressSuccess) {
- sampleCount pcmNumSamples = mixer->Process(pcmBufferSize);
+ while (updateResult == eProgressSuccess) {
+ sampleCount pcmNumSamples = mixer->Process(pcmBufferSize);
- if (pcmNumSamples == 0)
- break;
+ if (pcmNumSamples == 0)
+ break;
- short *pcmBuffer = (short *)mixer->GetBuffer();
+ short *pcmBuffer = (short *)mixer->GetBuffer();
- EncodeAudioFrame(pcmBuffer,(pcmNumSamples)*sizeof(int16_t)*mChannels);
+ EncodeAudioFrame(pcmBuffer, (pcmNumSamples)*sizeof(int16_t)*mChannels);
- updateResult = progress->Update(mixer->MixGetCurrentTime()-t0, t1-t0);
+ updateResult = progress.Update(mixer->MixGetCurrentTime() - t0, t1 - t0);
+ }
}
- delete progress;
-
delete mixer;
Finalize();
diff --git a/src/export/ExportFLAC.cpp b/src/export/ExportFLAC.cpp
index cbba97e13..b44d78c1e 100644
--- a/src/export/ExportFLAC.cpp
+++ b/src/export/ExportFLAC.cpp
@@ -325,38 +325,38 @@ int ExportFLAC::Export(AudacityProject *project,
tmpsmplbuf[i] = (FLAC__int32 *) calloc(SAMPLES_PER_RUN, sizeof(FLAC__int32));
}
- ProgressDialog *progress = new ProgressDialog(wxFileName(fName).GetName(),
+ {
+ ProgressDialog progress(wxFileName(fName).GetName(),
selectionOnly ?
_("Exporting the selected audio as FLAC") :
_("Exporting the entire project as FLAC"));
- while (updateResult == eProgressSuccess) {
- sampleCount samplesThisRun = mixer->Process(SAMPLES_PER_RUN);
- if (samplesThisRun == 0) { //stop encoding
- break;
- }
- else {
- for (i = 0; i < numChannels; i++) {
- samplePtr mixed = mixer->GetBuffer(i);
- if (format == int24Sample) {
- for (j = 0; j < samplesThisRun; j++) {
- tmpsmplbuf[i][j] = ((int *) mixed)[j];
- }
- }
- else {
- for (j = 0; j < samplesThisRun; j++) {
- tmpsmplbuf[i][j] = ((short *) mixed)[j];
- }
- }
+ while (updateResult == eProgressSuccess) {
+ sampleCount samplesThisRun = mixer->Process(SAMPLES_PER_RUN);
+ if (samplesThisRun == 0) { //stop encoding
+ break;
}
- encoder.process(tmpsmplbuf, samplesThisRun);
+ else {
+ for (i = 0; i < numChannels; i++) {
+ samplePtr mixed = mixer->GetBuffer(i);
+ if (format == int24Sample) {
+ for (j = 0; j < samplesThisRun; j++) {
+ tmpsmplbuf[i][j] = ((int *)mixed)[j];
+ }
+ }
+ else {
+ for (j = 0; j < samplesThisRun; j++) {
+ tmpsmplbuf[i][j] = ((short *)mixed)[j];
+ }
+ }
+ }
+ encoder.process(tmpsmplbuf, samplesThisRun);
+ }
+ updateResult = progress.Update(mixer->MixGetCurrentTime() - t0, t1 - t0);
}
- updateResult = progress->Update(mixer->MixGetCurrentTime()-t0, t1-t0);
+ f.Detach(); // libflac closes the file
+ encoder.finish();
}
- f.Detach(); // libflac closes the file
- encoder.finish();
-
- delete progress;
for (i = 0; i < numChannels; i++) {
free(tmpsmplbuf[i]);
diff --git a/src/export/ExportMP2.cpp b/src/export/ExportMP2.cpp
index d7339a2ff..1388fdd0c 100644
--- a/src/export/ExportMP2.cpp
+++ b/src/export/ExportMP2.cpp
@@ -272,36 +272,36 @@ int ExportMP2::Export(AudacityProject *project,
t0, t1,
stereo? 2: 1, pcmBufferSize, true,
rate, int16Sample, true, mixerSpec);
- delete [] waveTracks;
-
- ProgressDialog *progress = new ProgressDialog(wxFileName(fName).GetName(),
- selectionOnly ?
- wxString::Format(_("Exporting selected audio at %ld kbps"), bitrate) :
- wxString::Format(_("Exporting entire file at %ld kbps"), bitrate));
+ delete[] waveTracks;
int updateResult = eProgressSuccess;
- while(updateResult == eProgressSuccess) {
- sampleCount pcmNumSamples = mixer->Process(pcmBufferSize);
+ {
+ ProgressDialog progress(wxFileName(fName).GetName(),
+ selectionOnly ?
+ wxString::Format(_("Exporting selected audio at %ld kbps"), bitrate) :
+ wxString::Format(_("Exporting entire file at %ld kbps"), bitrate));
- if (pcmNumSamples == 0)
- break;
+ while (updateResult == eProgressSuccess) {
+ sampleCount pcmNumSamples = mixer->Process(pcmBufferSize);
- short *pcmBuffer = (short *)mixer->GetBuffer();
+ if (pcmNumSamples == 0)
+ break;
- int mp2BufferNumBytes = twolame_encode_buffer_interleaved(
+ short *pcmBuffer = (short *)mixer->GetBuffer();
+
+ int mp2BufferNumBytes = twolame_encode_buffer_interleaved(
encodeOptions,
pcmBuffer,
pcmNumSamples,
mp2Buffer,
mp2BufferSize);
- outFile.Write(mp2Buffer, mp2BufferNumBytes);
+ outFile.Write(mp2Buffer, mp2BufferNumBytes);
- updateResult = progress->Update(mixer->MixGetCurrentTime()-t0, t1-t0);
+ updateResult = progress.Update(mixer->MixGetCurrentTime() - t0, t1 - t0);
+ }
}
- delete progress;
-
delete mixer;
int mp2BufferNumBytes = twolame_encode_flush(
diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp
index 53dd06d20..9ca54cab2 100644
--- a/src/export/ExportMP3.cpp
+++ b/src/export/ExportMP3.cpp
@@ -1792,48 +1792,48 @@ int ExportMP3::Export(AudacityProject *project,
brate);
}
- ProgressDialog *progress = new ProgressDialog(wxFileName(fName).GetName(), title);
+ {
+ ProgressDialog progress(wxFileName(fName).GetName(), title);
- while (updateResult == eProgressSuccess) {
- sampleCount blockLen = mixer->Process(inSamples);
+ while (updateResult == eProgressSuccess) {
+ sampleCount blockLen = mixer->Process(inSamples);
- if (blockLen == 0) {
- break;
- }
+ if (blockLen == 0) {
+ break;
+ }
- short *mixed = (short *)mixer->GetBuffer();
+ short *mixed = (short *)mixer->GetBuffer();
- if (blockLen < inSamples) {
- if (channels > 1) {
- bytes = exporter.EncodeRemainder(mixed, blockLen , buffer);
+ if (blockLen < inSamples) {
+ if (channels > 1) {
+ bytes = exporter.EncodeRemainder(mixed, blockLen, buffer);
+ }
+ else {
+ bytes = exporter.EncodeRemainderMono(mixed, blockLen, buffer);
+ }
}
else {
- bytes = exporter.EncodeRemainderMono(mixed, blockLen , buffer);
+ if (channels > 1) {
+ bytes = exporter.EncodeBuffer(mixed, buffer);
+ }
+ else {
+ bytes = exporter.EncodeBufferMono(mixed, buffer);
+ }
}
- }
- else {
- if (channels > 1) {
- bytes = exporter.EncodeBuffer(mixed, buffer);
- }
- else {
- bytes = exporter.EncodeBufferMono(mixed, buffer);
+
+ if (bytes < 0) {
+ wxString msg;
+ msg.Printf(_("Error %ld returned from MP3 encoder"), bytes);
+ wxMessageBox(msg);
+ break;
}
+
+ outFile.Write(buffer, bytes);
+
+ updateResult = progress.Update(mixer->MixGetCurrentTime() - t0, t1 - t0);
}
-
- if (bytes < 0) {
- wxString msg;
- msg.Printf(_("Error %ld returned from MP3 encoder"), bytes);
- wxMessageBox(msg);
- break;
- }
-
- outFile.Write(buffer, bytes);
-
- updateResult = progress->Update(mixer->MixGetCurrentTime()-t0, t1-t0);
}
- delete progress;
-
delete mixer;
bytes = exporter.FinishStream(buffer);
diff --git a/src/export/ExportOGG.cpp b/src/export/ExportOGG.cpp
index 09d7643af..d54da57fd 100644
--- a/src/export/ExportOGG.cpp
+++ b/src/export/ExportOGG.cpp
@@ -253,74 +253,74 @@ int ExportOGG::Export(AudacityProject *project,
t0, t1,
numChannels, SAMPLES_PER_RUN, false,
rate, floatSample, true, mixerSpec);
- delete [] waveTracks;
+ delete[] waveTracks;
- ProgressDialog *progress = new ProgressDialog(wxFileName(fName).GetName(),
- selectionOnly ?
- _("Exporting the selected audio as Ogg Vorbis") :
- _("Exporting the entire project as Ogg Vorbis"));
+ {
+ ProgressDialog progress(wxFileName(fName).GetName(),
+ selectionOnly ?
+ _("Exporting the selected audio as Ogg Vorbis") :
+ _("Exporting the entire project as Ogg Vorbis"));
- while (updateResult == eProgressSuccess && !eos) {
- float **vorbis_buffer = vorbis_analysis_buffer(&dsp, SAMPLES_PER_RUN);
- sampleCount samplesThisRun = mixer->Process(SAMPLES_PER_RUN);
+ while (updateResult == eProgressSuccess && !eos) {
+ float **vorbis_buffer = vorbis_analysis_buffer(&dsp, SAMPLES_PER_RUN);
+ sampleCount samplesThisRun = mixer->Process(SAMPLES_PER_RUN);
- if (samplesThisRun == 0) {
- // Tell the library that we wrote 0 bytes - signalling the end.
- vorbis_analysis_wrote(&dsp, 0);
- }
- else {
+ if (samplesThisRun == 0) {
+ // Tell the library that we wrote 0 bytes - signalling the end.
+ vorbis_analysis_wrote(&dsp, 0);
+ }
+ else {
- for (int i = 0; i < numChannels; i++) {
- float *temp = (float *)mixer->GetBuffer(i);
- memcpy(vorbis_buffer[i], temp, sizeof(float)*SAMPLES_PER_RUN);
+ for (int i = 0; i < numChannels; i++) {
+ float *temp = (float *)mixer->GetBuffer(i);
+ memcpy(vorbis_buffer[i], temp, sizeof(float)*SAMPLES_PER_RUN);
+ }
+
+ // tell the encoder how many samples we have
+ vorbis_analysis_wrote(&dsp, samplesThisRun);
}
- // tell the encoder how many samples we have
- vorbis_analysis_wrote(&dsp, samplesThisRun);
- }
+ // I don't understand what this call does, so here is the comment
+ // from the example, verbatim:
+ //
+ // vorbis does some data preanalysis, then divvies up blocks
+ // for more involved (potentially parallel) processing. Get
+ // a single block for encoding now
+ while (vorbis_analysis_blockout(&dsp, &block) == 1) {
- // I don't understand what this call does, so here is the comment
- // from the example, verbatim:
- //
- // vorbis does some data preanalysis, then divvies up blocks
- // for more involved (potentially parallel) processing. Get
- // a single block for encoding now
- while (vorbis_analysis_blockout(&dsp, &block) == 1) {
+ // analysis, assume we want to use bitrate management
+ vorbis_analysis(&block, NULL);
+ vorbis_bitrate_addblock(&block);
- // analysis, assume we want to use bitrate management
- vorbis_analysis(&block, NULL);
- vorbis_bitrate_addblock(&block);
+ while (vorbis_bitrate_flushpacket(&dsp, &packet)) {
- while (vorbis_bitrate_flushpacket(&dsp, &packet)) {
+ // add the packet to the bitstream
+ ogg_stream_packetin(&stream, &packet);
- // add the packet to the bitstream
- ogg_stream_packetin(&stream, &packet);
+ // From vorbis-tools-1.0/oggenc/encode.c:
+ // If we've gone over a page boundary, we can do actual output,
+ // so do so (for however many pages are available).
- // From vorbis-tools-1.0/oggenc/encode.c:
- // If we've gone over a page boundary, we can do actual output,
- // so do so (for however many pages are available).
+ while (!eos) {
+ int result = ogg_stream_pageout(&stream, &page);
+ if (!result) {
+ break;
+ }
- while (!eos) {
- int result = ogg_stream_pageout(&stream, &page);
- if (!result) {
- break;
- }
+ outFile.Write(page.header, page.header_len);
+ outFile.Write(page.body, page.body_len);
- outFile.Write(page.header, page.header_len);
- outFile.Write(page.body, page.body_len);
-
- if (ogg_page_eos(&page)) {
- eos = 1;
+ if (ogg_page_eos(&page)) {
+ eos = 1;
+ }
}
}
}
+
+ updateResult = progress.Update(mixer->MixGetCurrentTime() - t0, t1 - t0);
}
-
- updateResult = progress->Update(mixer->MixGetCurrentTime()-t0, t1-t0);
}
- delete progress;;
-
delete mixer;
ogg_stream_clear(&stream);
diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp
index 2e40daaea..e5fa34cfb 100644
--- a/src/export/ExportPCM.cpp
+++ b/src/export/ExportPCM.cpp
@@ -493,47 +493,47 @@ int ExportPCM::Export(AudacityProject *project,
info.channels, maxBlockLen, true,
rate, format, true, mixerSpec);
- ProgressDialog *progress = new ProgressDialog(wxFileName(fName).GetName(),
- selectionOnly ?
- wxString::Format(_("Exporting the selected audio as %s"),
- formatStr.c_str()) :
- wxString::Format(_("Exporting the entire project as %s"),
- formatStr.c_str()));
+ {
+ ProgressDialog progress(wxFileName(fName).GetName(),
+ selectionOnly ?
+ wxString::Format(_("Exporting the selected audio as %s"),
+ formatStr.c_str()) :
+ wxString::Format(_("Exporting the entire project as %s"),
+ formatStr.c_str()));
- while(updateResult == eProgressSuccess) {
- sampleCount samplesWritten;
- sampleCount numSamples = mixer->Process(maxBlockLen);
+ while (updateResult == eProgressSuccess) {
+ sampleCount samplesWritten;
+ sampleCount numSamples = mixer->Process(maxBlockLen);
- if (numSamples == 0)
- break;
+ if (numSamples == 0)
+ break;
- samplePtr mixed = mixer->GetBuffer();
+ samplePtr mixed = mixer->GetBuffer();
- ODManager::LockLibSndFileMutex();
- if (format == int16Sample)
- samplesWritten = sf_writef_short(sf, (short *)mixed, numSamples);
- else
- samplesWritten = sf_writef_float(sf, (float *)mixed, numSamples);
- ODManager::UnlockLibSndFileMutex();
+ ODManager::LockLibSndFileMutex();
+ if (format == int16Sample)
+ samplesWritten = sf_writef_short(sf, (short *)mixed, numSamples);
+ else
+ samplesWritten = sf_writef_float(sf, (float *)mixed, numSamples);
+ ODManager::UnlockLibSndFileMutex();
- if (samplesWritten != numSamples) {
- char buffer2[1000];
- sf_error_str(sf, buffer2, 1000);
- wxMessageBox(wxString::Format(
- /* i18n-hint: %s will be the error message from libsndfile, which
- * is usually something unhelpful (and untranslated) like "system
- * error" */
- _("Error while writing %s file (disk full?).\nLibsndfile says \"%s\""),
- formatStr.c_str(),
- wxString::FromAscii(buffer2).c_str()));
- break;
+ if (samplesWritten != numSamples) {
+ char buffer2[1000];
+ sf_error_str(sf, buffer2, 1000);
+ wxMessageBox(wxString::Format(
+ /* i18n-hint: %s will be the error message from libsndfile, which
+ * is usually something unhelpful (and untranslated) like "system
+ * error" */
+ _("Error while writing %s file (disk full?).\nLibsndfile says \"%s\""),
+ formatStr.c_str(),
+ wxString::FromAscii(buffer2).c_str()));
+ break;
+ }
+
+ updateResult = progress.Update(mixer->MixGetCurrentTime() - t0, t1 - t0);
}
-
- updateResult = progress->Update(mixer->MixGetCurrentTime()-t0, t1-t0);
}
- delete progress;
-
delete mixer;
delete[] waveTracks;
diff --git a/src/import/ImportFFmpeg.cpp b/src/import/ImportFFmpeg.cpp
index df0a5d345..ed50a5252 100644
--- a/src/import/ImportFFmpeg.cpp
+++ b/src/import/ImportFFmpeg.cpp
@@ -310,15 +310,12 @@ ImportFileHandle *FFmpegImportPlugin::Open(wxString filename)
if (!FFmpegLibsInst->ValidLibsLoaded())
{
int dontShowDlg;
- FFmpegNotFoundDialog *dlg;
gPrefs->Read(wxT("/FFmpeg/NotFoundDontShow"),&dontShowDlg,0);
if (dontShowDlg == 0 && newsession)
{
gPrefs->Write(wxT("/NewImportingSession"), false);
gPrefs->Flush();
- dlg = new FFmpegNotFoundDialog(NULL);
- dlg->ShowModal();
- delete dlg;
+ FFmpegNotFoundDialog{ nullptr }.ShowModal();
}
}
}
diff --git a/src/toolbars/ControlToolBar.cpp b/src/toolbars/ControlToolBar.cpp
index 39f3add51..39fe8fdd3 100644
--- a/src/toolbars/ControlToolBar.cpp
+++ b/src/toolbars/ControlToolBar.cpp
@@ -832,7 +832,8 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
// If SHIFT key was down, the user wants append to tracks
int recordingChannels = 0;
- TrackList *tracksCopy = NULL;
+ TrackList tracksCopy(true);
+ bool tracksCopied = false;
bool shifted = mRecord->WasShiftDown();
if (shifted) {
bool sel = false;
@@ -872,12 +873,12 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
playbackTracks.Remove(wt);
t1 = wt->GetEndTime();
if (t1 < t0) {
- if (!tracksCopy) {
- tracksCopy = new TrackList();
+ if (!tracksCopied) {
+ tracksCopied = true;
TrackListIterator iter(t);
Track *trk = iter.First();
while (trk) {
- tracksCopy->Add(trk->Duplicate());
+ tracksCopy.Add(trk->Duplicate());
trk = iter.Next();
}
}
@@ -1000,17 +1001,13 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
if (success) {
p->SetAudioIOToken(token);
mBusyProject = p;
- if (shifted && tracksCopy) {
- tracksCopy->Clear(true);
- delete tracksCopy;
- }
}
else {
if (shifted) {
// Restore the tracks to remove any inserted silence
- if (tracksCopy) {
+ if (tracksCopied) {
t->Clear(true);
- TrackListIterator iter(tracksCopy);
+ TrackListIterator iter(&tracksCopy);
Track *trk = iter.First();
while (trk)
{
@@ -1018,7 +1015,6 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
trk = iter.RemoveCurrent();
t->Add(tmp);
}
- delete tracksCopy;
}
}
else {
diff --git a/src/widgets/HelpSystem.cpp b/src/widgets/HelpSystem.cpp
index be9f31673..230732ee4 100644
--- a/src/widgets/HelpSystem.cpp
+++ b/src/widgets/HelpSystem.cpp
@@ -156,9 +156,9 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent,
// If this section (providing an icon) causes compilation errors on linux, comment it out for now.
// it will just mean that the icon is missing. Works OK on Windows.
#ifdef __WXMSW__
- wxIcon ic(wxICON(AudacityLogo));
+ wxIcon ic{ wxICON(AudacityLogo) };
#else
- wxIcon ic;
+ wxIcon ic{};
ic.CopyFromBitmap(theTheme.Bitmap(bmpAudacityLogo48x48));
#endif
pWnd->SetIcon( ic );
diff --git a/src/widgets/Meter.cpp b/src/widgets/Meter.cpp
index b0dbeb4f8..d27bba583 100644
--- a/src/widgets/Meter.cpp
+++ b/src/widgets/Meter.cpp
@@ -679,18 +679,18 @@ void Meter::OnMouse(wxMouseEvent &evt)
if (evt.RightDown() ||
(evt.ButtonDown() && mIconRect.Contains(evt.m_x, evt.m_y)))
{
- wxMenu *menu = new wxMenu();
+ wxMenu menu;
// Note: these should be kept in the same order as the enum
if (mIsInput) {
wxMenuItem *mi;
if (mMonitoring)
- mi = menu->Append(OnMonitorID, _("Stop Monitoring"));
+ mi = menu.Append(OnMonitorID, _("Stop Monitoring"));
else
- mi = menu->Append(OnMonitorID, _("Start Monitoring"));
+ mi = menu.Append(OnMonitorID, _("Start Monitoring"));
mi->Enable(!mActive || mMonitoring);
}
- menu->Append(OnPreferencesID, _("Preferences..."));
+ menu.Append(OnPreferencesID, _("Preferences..."));
if (evt.RightDown()) {
ShowMenu(evt.GetPosition());
@@ -698,8 +698,6 @@ void Meter::OnMouse(wxMouseEvent &evt)
else {
ShowMenu(wxPoint(mIconRect.x + 1, mIconRect.y + mIconRect.height + 1));
}
-
- delete menu;
}
else if (evt.LeftDown()) {
if (mIsInput) {
@@ -1863,22 +1861,22 @@ void Meter::RestoreState(void *state)
void Meter::ShowMenu(const wxPoint & pos)
{
- wxMenu *menu = new wxMenu();
+ wxMenu menu;
// Note: these should be kept in the same order as the enum
if (mIsInput) {
wxMenuItem *mi;
if (mMonitoring)
- mi = menu->Append(OnMonitorID, _("Stop Monitoring"));
+ mi = menu.Append(OnMonitorID, _("Stop Monitoring"));
else
- mi = menu->Append(OnMonitorID, _("Start Monitoring"));
+ mi = menu.Append(OnMonitorID, _("Start Monitoring"));
mi->Enable(!mActive || mMonitoring);
}
- menu->Append(OnPreferencesID, _("Preferences..."));
+ menu.Append(OnPreferencesID, _("Preferences..."));
mAccSilent = true; // temporarily make screen readers say (close to) nothing on focus events
- PopupMenu(menu, pos);
+ PopupMenu(&menu, pos);
/* if stop/start monitoring was chosen in the menu, then by this point
OnMonitoring has been called and variables which affect the accessibility
@@ -1891,8 +1889,6 @@ void Meter::ShowMenu(const wxPoint & pos)
wxOBJID_CLIENT,
wxACC_SELF);
#endif
-
- delete menu;
}
void Meter::OnMonitor(wxCommandEvent & WXUNUSED(event))
diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp
index 4f30826b8..8e66473f1 100644
--- a/src/widgets/Ruler.cpp
+++ b/src/widgets/Ruler.cpp
@@ -2237,42 +2237,43 @@ void AdornedRulerPanel::OnCaptureLost(wxMouseCaptureLostEvent & WXUNUSED(evt))
void AdornedRulerPanel::ShowMenu(const wxPoint & pos)
{
- wxMenu *rulerMenu = new wxMenu();
+ {
+ wxMenu rulerMenu;
- if (mQuickPlayEnabled)
- rulerMenu->Append(OnToggleQuickPlayID, _("Disable Quick-Play"));
- else
- rulerMenu->Append(OnToggleQuickPlayID, _("Enable Quick-Play"));
+ if (mQuickPlayEnabled)
+ rulerMenu.Append(OnToggleQuickPlayID, _("Disable Quick-Play"));
+ else
+ rulerMenu.Append(OnToggleQuickPlayID, _("Enable Quick-Play"));
- wxMenuItem *dragitem;
- if (mPlayRegionDragsSelection && !mProject->IsPlayRegionLocked())
- dragitem = rulerMenu->Append(OnSyncQuickPlaySelID, _("Disable dragging selection"));
- else
- dragitem = rulerMenu->Append(OnSyncQuickPlaySelID, _("Enable dragging selection"));
- dragitem->Enable(mQuickPlayEnabled && !mProject->IsPlayRegionLocked());
+ wxMenuItem *dragitem;
+ if (mPlayRegionDragsSelection && !mProject->IsPlayRegionLocked())
+ dragitem = rulerMenu.Append(OnSyncQuickPlaySelID, _("Disable dragging selection"));
+ else
+ dragitem = rulerMenu.Append(OnSyncQuickPlaySelID, _("Enable dragging selection"));
+ dragitem->Enable(mQuickPlayEnabled && !mProject->IsPlayRegionLocked());
#if wxUSE_TOOLTIPS
- if (mTimelineToolTip)
- rulerMenu->Append(OnTimelineToolTipID, _("Disable Timeline Tooltips"));
- else
- rulerMenu->Append(OnTimelineToolTipID, _("Enable Timeline Tooltips"));
+ if (mTimelineToolTip)
+ rulerMenu.Append(OnTimelineToolTipID, _("Disable Timeline Tooltips"));
+ else
+ rulerMenu.Append(OnTimelineToolTipID, _("Enable Timeline Tooltips"));
#endif
- if (mViewInfo->bUpdateTrackIndicator)
- rulerMenu->Append(OnAutoScrollID, _("Do not scroll while playing"));
- else
- rulerMenu->Append(OnAutoScrollID, _("Update display while playing"));
+ if (mViewInfo->bUpdateTrackIndicator)
+ rulerMenu.Append(OnAutoScrollID, _("Do not scroll while playing"));
+ else
+ rulerMenu.Append(OnAutoScrollID, _("Update display while playing"));
- wxMenuItem *prlitem;
- if (!mProject->IsPlayRegionLocked())
- prlitem = rulerMenu->Append(OnLockPlayRegionID, _("Lock Play Region"));
- else
- prlitem = rulerMenu->Append(OnLockPlayRegionID, _("Unlock Play Region"));
- prlitem->Enable(mProject->IsPlayRegionLocked() || (mPlayRegionStart != mPlayRegionEnd));
+ wxMenuItem *prlitem;
+ if (!mProject->IsPlayRegionLocked())
+ prlitem = rulerMenu.Append(OnLockPlayRegionID, _("Lock Play Region"));
+ else
+ prlitem = rulerMenu.Append(OnLockPlayRegionID, _("Unlock Play Region"));
+ prlitem->Enable(mProject->IsPlayRegionLocked() || (mPlayRegionStart != mPlayRegionEnd));
- PopupMenu(rulerMenu, pos);
+ PopupMenu(&rulerMenu, pos);
+ }
- delete rulerMenu;
// dismiss and clear Quick-Play indicator
mQuickPlayInd = false;
DrawQuickPlayIndicator(NULL);