diff --git a/src/AudioIOListener.h b/src/AudioIOListener.h index 054e6ff65..29f110143 100644 --- a/src/AudioIOListener.h +++ b/src/AudioIOListener.h @@ -15,8 +15,6 @@ #include "Audacity.h" -class AutoSaveFile; - class AUDACITY_DLL_API AudioIOListener /* not final */ { public: AudioIOListener() {} diff --git a/src/AutoRecovery.cpp b/src/AutoRecovery.cpp index a4ac5ade9..5a55f6ee0 100644 --- a/src/AutoRecovery.cpp +++ b/src/AutoRecovery.cpp @@ -219,22 +219,6 @@ void AutoSaveFile::WriteSubTree(const AutoSaveFile & value) mBuffer.AppendByte(FT_Pop); } -bool AutoSaveFile::Write(wxFFile & file) const -{ - return Append(file); -} - -bool AutoSaveFile::Append(wxFFile & file) const -{ - bool success = file.Write(mDict.GetData(), mDict.GetDataLen()) == mDict.GetDataLen(); - if (success) - { - success = file.Write(mBuffer.GetData(), mBuffer.GetDataLen()) == mBuffer.GetDataLen(); - } - - return success; -} - void AutoSaveFile::WriteName(const wxString & name) { wxASSERT(name.length() * sizeof(wxChar) <= SHRT_MAX); diff --git a/src/AutoRecovery.h b/src/AutoRecovery.h index 139918e05..03023d12d 100644 --- a/src/AutoRecovery.h +++ b/src/AutoRecovery.h @@ -55,9 +55,6 @@ public: // Non-override functions void WriteSubTree(const AutoSaveFile & value); - bool Write(wxFFile & file) const; - bool Append(wxFFile & file) const; - const wxMemoryBuffer &GetDict() const; const wxMemoryBuffer &GetData() const; diff --git a/src/LabelTrack.cpp b/src/LabelTrack.cpp index 4db0675c1..267383e22 100644 --- a/src/LabelTrack.cpp +++ b/src/LabelTrack.cpp @@ -68,11 +68,11 @@ static ProjectFileIORegistry::Entry registerFactory{ LabelTrack::Holder TrackFactory::NewLabelTrack() { - return std::make_shared(&mProject); + return std::make_shared(); } -LabelTrack::LabelTrack(AudacityProject *project): - Track(project), +LabelTrack::LabelTrack(): + Track(), mClipLen(0.0), miLastLabel(-1) { @@ -652,7 +652,7 @@ Track::Holder LabelTrack::SplitCut(double t0, double t1) Track::Holder LabelTrack::Copy(double t0, double t1, bool) const { - auto tmp = std::make_shared(GetProject()); + auto tmp = std::make_shared(); const auto lt = static_cast(tmp.get()); for (auto &labelStruct: mLabels) { diff --git a/src/LabelTrack.h b/src/LabelTrack.h index 48fd3792c..98f334f02 100644 --- a/src/LabelTrack.h +++ b/src/LabelTrack.h @@ -87,7 +87,7 @@ class AUDACITY_DLL_API LabelTrack final , public wxEvtHandler { public: - LabelTrack(AudacityProject *project); + LabelTrack(); LabelTrack(const LabelTrack &orig); virtual ~ LabelTrack(); diff --git a/src/NoteTrack.cpp b/src/NoteTrack.cpp index faec011a1..f9389b831 100644 --- a/src/NoteTrack.cpp +++ b/src/NoteTrack.cpp @@ -123,11 +123,11 @@ static ProjectFileIORegistry::Entry registerFactory{ NoteTrack::Holder TrackFactory::NewNoteTrack() { - return std::make_shared(&mProject); + return std::make_shared(); } -NoteTrack::NoteTrack(AudacityProject *project) - : NoteTrackBase(project) +NoteTrack::NoteTrack() + : NoteTrackBase() { SetDefaultName(_("Note Track")); SetName(GetDefaultName()); @@ -172,7 +172,7 @@ Alg_seq &NoteTrack::GetSeq() const Track::Holder NoteTrack::Clone() const { - auto duplicate = std::make_shared(mProject); + auto duplicate = std::make_shared(); duplicate->Init(*this); // The duplicate begins life in serialized state. Often the duplicate is // pushed on the Undo stack. Then we want to un-serialize it (or a further @@ -463,7 +463,7 @@ Track::Holder NoteTrack::Cut(double t0, double t1) //( std::min( t1, GetEndTime() ) ) - ( std::max( t0, GetStartTime() ) ) //); - auto newTrack = std::make_shared(mProject); + auto newTrack = std::make_shared(); newTrack->Init(*this); @@ -477,7 +477,7 @@ Track::Holder NoteTrack::Cut(double t0, double t1) //AddToDuration( delta ); // What should be done with the rest of newTrack's members? - //(mBottomNote, mProject, + //(mBottomNote, // mSerializationBuffer, mSerializationLength, mVisibleChannels) return newTrack; @@ -490,7 +490,7 @@ Track::Holder NoteTrack::Copy(double t0, double t1, bool) const double len = t1-t0; - auto newTrack = std::make_shared(mProject); + auto newTrack = std::make_shared(); newTrack->Init(*this); @@ -500,7 +500,7 @@ Track::Holder NoteTrack::Copy(double t0, double t1, bool) const newTrack->SetOffset(0); // What should be done with the rest of newTrack's members? - // (mBottomNote, mProject, mSerializationBuffer, + // (mBottomNote, mSerializationBuffer, // mSerializationLength, mVisibleChannels) return newTrack; diff --git a/src/NoteTrack.h b/src/NoteTrack.h index 716d17eb6..91295ce81 100644 --- a/src/NoteTrack.h +++ b/src/NoteTrack.h @@ -65,7 +65,7 @@ class AUDACITY_DLL_API NoteTrack final : public NoteTrackBase { public: - NoteTrack(AudacityProject *project); + NoteTrack(); virtual ~NoteTrack(); using Holder = std::shared_ptr; diff --git a/src/ProjectFileIO.cpp b/src/ProjectFileIO.cpp index 59cac034c..878b71a1d 100644 --- a/src/ProjectFileIO.cpp +++ b/src/ProjectFileIO.cpp @@ -1245,7 +1245,7 @@ const TranslatableString & ProjectFileIO::GetLastError() const const TranslatableString & ProjectFileIO::GetLibraryError() const { - return mLastError; + return mLibraryError; } void ProjectFileIO::SetError(const TranslatableString & msg) diff --git a/src/ProjectFileIO.h b/src/ProjectFileIO.h index 61b17bb23..d6bfab924 100644 --- a/src/ProjectFileIO.h +++ b/src/ProjectFileIO.h @@ -80,7 +80,6 @@ private: void UpdatePrefs() override; using ExecCB = std::function; - using ExecFunc = int (*)(void *data, int cols, char **vals, char **names); struct ExecParm { ExecCB func; diff --git a/src/SampleBlock.cpp b/src/SampleBlock.cpp index 99c08f70a..a0bb66bb2 100644 --- a/src/SampleBlock.cpp +++ b/src/SampleBlock.cpp @@ -144,8 +144,7 @@ SampleBlockPtr SampleBlock::Get(AudacityProject *project, } SampleBlock::SampleBlock(AudacityProject *project) -: mProject(project), - mIO(ProjectFileIO::Get(*project)) +: mIO(ProjectFileIO::Get(*project)) { mValid = false; mSilent = false; diff --git a/src/SampleBlock.h b/src/SampleBlock.h index 61798feeb..cdcac4b3e 100644 --- a/src/SampleBlock.h +++ b/src/SampleBlock.h @@ -103,7 +103,6 @@ private: void CalcSummary(); private: - AudacityProject *mProject; ProjectFileIO & mIO; bool mValid; bool mDirty; @@ -128,7 +127,6 @@ private: const char *columns = "sampleformat, summin, summax, sumrms, summary256, summary64k, samples"; - friend class ProjectFileIO; #if defined(WORDS_BIGENDIAN) #error All sample block data is little endian...big endian not yet supported #endif diff --git a/src/Sequence.cpp b/src/Sequence.cpp index e1c121cac..a7d265c02 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -40,7 +40,6 @@ #include #include -#include "ProjectFileIO.h" #include "SampleBlock.h" #include "InconsistencyException.h" #include "widgets/AudacityMessageBox.h" diff --git a/src/TimeTrack.cpp b/src/TimeTrack.cpp index fcd15ffab..b26136e9d 100644 --- a/src/TimeTrack.cpp +++ b/src/TimeTrack.cpp @@ -38,7 +38,7 @@ std::shared_ptr TrackFactory::NewTimeTrack() { - return std::make_shared(&mProject, mZoomInfo); + return std::make_shared(mZoomInfo); } static ProjectFileIORegistry::Entry registerFactory{ @@ -53,8 +53,8 @@ static ProjectFileIORegistry::Entry registerFactory{ } }; -TimeTrack::TimeTrack(AudacityProject *project, const ZoomInfo *zoomInfo): - Track(project) +TimeTrack::TimeTrack(const ZoomInfo *zoomInfo): + Track() , mZoomInfo(zoomInfo) { mEnvelope = std::make_unique(true, TIMETRACK_MIN, TIMETRACK_MAX, 1.0); diff --git a/src/TimeTrack.h b/src/TimeTrack.h index 6807e8f02..6fad911dd 100644 --- a/src/TimeTrack.h +++ b/src/TimeTrack.h @@ -25,7 +25,7 @@ class TimeTrack final : public Track { public: - TimeTrack(AudacityProject *project, const ZoomInfo *zoomInfo); + TimeTrack(const ZoomInfo *zoomInfo); /** @brief Copy-Constructor - create a NEW TimeTrack:: which is an independent copy of the original * * Calls TimeTrack::Init() to copy the track metadata, then does a bunch of manipulations on the diff --git a/src/Track.cpp b/src/Track.cpp index df95f3031..87bb583d2 100644 --- a/src/Track.cpp +++ b/src/Track.cpp @@ -46,9 +46,8 @@ and TimeTrack. #pragma warning( disable : 4786 ) #endif -Track::Track(AudacityProject *project) -: vrulerSize(36,0), - mProject(project) +Track::Track() +: vrulerSize(36,0) { mSelected = false; mLinked = false; @@ -76,8 +75,6 @@ void Track::Init(const Track &orig) mDefaultName = orig.mDefaultName; mName = orig.mName; - mProject = orig.mProject; - mSelected = orig.mSelected; mLinked = orig.mLinked; mChannel = orig.mChannel; diff --git a/src/Track.h b/src/Track.h index 77d739d21..eab35bd5a 100644 --- a/src/Track.h +++ b/src/Track.h @@ -309,11 +309,9 @@ private: ChannelType mChannel; double mOffset; - mutable AudacityProject *mProject; - public: - Track(AudacityProject *project); + Track(); Track(const Track &orig); virtual ~ Track(); @@ -352,12 +350,6 @@ public: virtual void SetPan( float ){ ;} virtual void SetPanFromChannelType(){ ;}; - // AS: Note that the project is mutable. This is - // mostly to support "Duplicate" of const objects, - // but in general, mucking with the dir manager is - // separate from the Track. - AudacityProject *GetProject() const { return mProject; } - // Create a NEW track and modify this track // Return non-NULL or else throw // May assume precondition: t0 <= t1 @@ -716,8 +708,8 @@ protected: class AUDACITY_DLL_API AudioTrack /* not final */ : public Track { public: - AudioTrack(AudacityProject *project) - : Track{ project } {} + AudioTrack() + : Track{} {} AudioTrack(const Track &orig) : Track{ orig } {} // Serialize, not with tags of its own, but as attributes within a tag. @@ -731,8 +723,8 @@ public: class AUDACITY_DLL_API PlayableTrack /* not final */ : public AudioTrack { public: - PlayableTrack(AudacityProject *project) - : AudioTrack{ project } {} + PlayableTrack() + : AudioTrack{} {} PlayableTrack(const Track &orig) : AudioTrack{ orig } {} bool GetMute () const { return mMute; } diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 37f6440f6..a14604f3b 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -47,7 +47,6 @@ Track classes. #include "Sequence.h" #include "Spectrum.h" -#include "Project.h" #include "ProjectFileIORegistry.h" #include "ProjectSettings.h" @@ -94,8 +93,10 @@ WaveTrack::Holder TrackFactory::NewWaveTrack(sampleFormat format, double rate) return std::make_shared ( &mProject, format, rate ); } -WaveTrack::WaveTrack(AudacityProject *project, sampleFormat format, double rate) : - PlayableTrack(project) +WaveTrack::WaveTrack( AudacityProject *project, + sampleFormat format, double rate ) + : PlayableTrack() + , mProject(project) { mLegacyProjectFileOffset = 0; @@ -142,6 +143,8 @@ WaveTrack::WaveTrack(const WaveTrack &orig): void WaveTrack::Init(const WaveTrack &orig) { PlayableTrack::Init(orig); + mProject = orig.mProject; + mFormat = orig.mFormat; mWaveColorIndex = orig.mWaveColorIndex; mRate = orig.mRate; diff --git a/src/WaveTrack.h b/src/WaveTrack.h index a105c69a3..b5b866f35 100644 --- a/src/WaveTrack.h +++ b/src/WaveTrack.h @@ -577,6 +577,10 @@ private: // Private variables // + // AS: Note that the mProject is mutable. This is + // mostly to support "Duplicate" of const objects + mutable AudacityProject *mProject; + wxCriticalSection mFlushCriticalSection; wxCriticalSection mAppendCriticalSection; double mLegacyProjectFileOffset;