From 5162ab5c5bffaef86b6ae4ead1dcf3e37a87126a Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 14 Mar 2016 18:11:09 -0400 Subject: [PATCH] Use TrackFactory in more places... ... There should now be no direct allocation of Track subclasses with new, except in those classes' own methods --- src/LabelDialog.cpp | 10 +++++----- src/LabelDialog.h | 6 +++--- src/Menus.cpp | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/LabelDialog.cpp b/src/LabelDialog.cpp index 5463a0e19..47a98d0e6 100644 --- a/src/LabelDialog.cpp +++ b/src/LabelDialog.cpp @@ -86,7 +86,7 @@ BEGIN_EVENT_TABLE(LabelDialog, wxDialog) END_EVENT_TABLE() LabelDialog::LabelDialog(wxWindow *parent, - DirManager *dirmanager, + TrackFactory &factory, TrackList *tracks, ViewInfo &viewinfo, double rate, @@ -97,7 +97,7 @@ LabelDialog::LabelDialog(wxWindow *parent, wxDefaultPosition, wxSize(800, 600), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), - mDirManager(dirmanager), + mFactory(factory), mTracks(tracks), mViewInfo(&viewinfo), mRate(rate), @@ -319,7 +319,7 @@ bool LabelDialog::TransferDataFromWindow() wxString name = mTrackNames[tndx + 1].AfterFirst(wxT('-')).Mid(1); // Create the NEW track and add to track list - LabelTrack *newTrack = new LabelTrack(mDirManager); + LabelTrack *newTrack = mFactory.NewLabelTrack(); newTrack->SetName(name); mTracks->Add(newTrack); tndx++; @@ -564,7 +564,7 @@ void LabelDialog::OnImport(wxCommandEvent & WXUNUSED(event)) else { // Create a temporary label track and load the labels // into it - LabelTrack *lt = new LabelTrack(mDirManager); + LabelTrack *lt = mFactory.NewLabelTrack(); lt->Import(f); // Add the labesls to our collection @@ -632,7 +632,7 @@ void LabelDialog::OnExport(wxCommandEvent & WXUNUSED(event)) } // Transfer our collection to a temporary label track - LabelTrack *lt = new LabelTrack(mDirManager); + LabelTrack *lt = mFactory.NewLabelTrack(); int i; for (i = 0; i < cnt; i++) { diff --git a/src/LabelDialog.h b/src/LabelDialog.h index 76a255cc0..35a3e9946 100644 --- a/src/LabelDialog.h +++ b/src/LabelDialog.h @@ -21,7 +21,7 @@ #include "Internat.h" #include "widgets/Grid.h" -class DirManager; +class TrackFactory; class TrackList; class RowData; class EmptyLabelRenderer; @@ -35,7 +35,7 @@ class LabelDialog final : public wxDialog public: LabelDialog(wxWindow *parent, - DirManager *dirmanager, + TrackFactory &factory, TrackList *tracks, ViewInfo &viewinfo, double rate, @@ -76,7 +76,7 @@ class LabelDialog final : public wxDialog RowDataArray mData; - DirManager *mDirManager; + TrackFactory &mFactory; TrackList *mTracks; ViewInfo *mViewInfo; wxArrayString mTrackNames; diff --git a/src/Menus.cpp b/src/Menus.cpp index a54d01d70..08799e6d3 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -4358,7 +4358,7 @@ void AudacityProject::OnPasteNewLabel() // If no match found, add one if (!t) { - t = new LabelTrack(mDirManager); + t = GetTrackFactory()->NewLabelTrack(); mTracks->Add(t); } @@ -5495,7 +5495,7 @@ void AudacityProject::OnImportLabels() return; } - LabelTrack *newTrack = new LabelTrack(mDirManager); + LabelTrack *newTrack = GetTrackFactory()->NewLabelTrack(); wxString sTrackName; wxFileName::SplitPath(fileName, NULL, NULL, &sTrackName, NULL); newTrack->SetName(sTrackName); @@ -5538,7 +5538,7 @@ void AudacityProject::OnImportMIDI() void AudacityProject::DoImportMIDI(const wxString &fileName) { - NoteTrack *newTrack = new NoteTrack(mDirManager); + NoteTrack *newTrack = GetTrackFactory()->NewNoteTrack(); if (::ImportMIDI(fileName, newTrack)) { @@ -6289,7 +6289,7 @@ void AudacityProject::OnNewStereoTrack() void AudacityProject::OnNewLabelTrack() { - LabelTrack *t = new LabelTrack(mDirManager); + LabelTrack *t = GetTrackFactory()->NewLabelTrack(); SelectNone(); @@ -6385,7 +6385,7 @@ int AudacityProject::DoAddLabel(const SelectedRegion ®ion, bool preserveFocus // If none found, start a NEW label track and use it if (!lt) { - lt = new LabelTrack(mDirManager); + lt = GetTrackFactory()->NewLabelTrack(); mTracks->Add(lt); } @@ -6455,7 +6455,7 @@ void AudacityProject::OnEditLabels() { wxString format = GetSelectionFormat(); - LabelDialog dlg(this, mDirManager, mTracks, mViewInfo, mRate, format); + LabelDialog dlg(this, *GetTrackFactory(), mTracks, mViewInfo, mRate, format); if (dlg.ShowModal() == wxID_OK) { PushState(_("Edited labels"), _("Label"));