1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Unitary fixes (#598)

* Eliminate unneeded back-pointer to project from non-wave Tracks...

... now that DirManager is gone

* Remove unused declarations

* SampleData::mProject was not used

* Correct ProjectFileIO::GetLibraryError

* Remove unnecessary #include directives
This commit is contained in:
Paul Licameli 2020-07-02 12:42:25 -04:00 committed by GitHub
parent e7fd679ae6
commit 1fcb77ebce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 37 additions and 67 deletions

View File

@ -15,8 +15,6 @@
#include "Audacity.h" #include "Audacity.h"
class AutoSaveFile;
class AUDACITY_DLL_API AudioIOListener /* not final */ { class AUDACITY_DLL_API AudioIOListener /* not final */ {
public: public:
AudioIOListener() {} AudioIOListener() {}

View File

@ -219,22 +219,6 @@ void AutoSaveFile::WriteSubTree(const AutoSaveFile & value)
mBuffer.AppendByte(FT_Pop); 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) void AutoSaveFile::WriteName(const wxString & name)
{ {
wxASSERT(name.length() * sizeof(wxChar) <= SHRT_MAX); wxASSERT(name.length() * sizeof(wxChar) <= SHRT_MAX);

View File

@ -55,9 +55,6 @@ public:
// Non-override functions // Non-override functions
void WriteSubTree(const AutoSaveFile & value); void WriteSubTree(const AutoSaveFile & value);
bool Write(wxFFile & file) const;
bool Append(wxFFile & file) const;
const wxMemoryBuffer &GetDict() const; const wxMemoryBuffer &GetDict() const;
const wxMemoryBuffer &GetData() const; const wxMemoryBuffer &GetData() const;

View File

@ -68,11 +68,11 @@ static ProjectFileIORegistry::Entry registerFactory{
LabelTrack::Holder TrackFactory::NewLabelTrack() LabelTrack::Holder TrackFactory::NewLabelTrack()
{ {
return std::make_shared<LabelTrack>(&mProject); return std::make_shared<LabelTrack>();
} }
LabelTrack::LabelTrack(AudacityProject *project): LabelTrack::LabelTrack():
Track(project), Track(),
mClipLen(0.0), mClipLen(0.0),
miLastLabel(-1) miLastLabel(-1)
{ {
@ -652,7 +652,7 @@ Track::Holder LabelTrack::SplitCut(double t0, double t1)
Track::Holder LabelTrack::Copy(double t0, double t1, bool) const Track::Holder LabelTrack::Copy(double t0, double t1, bool) const
{ {
auto tmp = std::make_shared<LabelTrack>(GetProject()); auto tmp = std::make_shared<LabelTrack>();
const auto lt = static_cast<LabelTrack*>(tmp.get()); const auto lt = static_cast<LabelTrack*>(tmp.get());
for (auto &labelStruct: mLabels) { for (auto &labelStruct: mLabels) {

View File

@ -87,7 +87,7 @@ class AUDACITY_DLL_API LabelTrack final
, public wxEvtHandler , public wxEvtHandler
{ {
public: public:
LabelTrack(AudacityProject *project); LabelTrack();
LabelTrack(const LabelTrack &orig); LabelTrack(const LabelTrack &orig);
virtual ~ LabelTrack(); virtual ~ LabelTrack();

View File

@ -123,11 +123,11 @@ static ProjectFileIORegistry::Entry registerFactory{
NoteTrack::Holder TrackFactory::NewNoteTrack() NoteTrack::Holder TrackFactory::NewNoteTrack()
{ {
return std::make_shared<NoteTrack>(&mProject); return std::make_shared<NoteTrack>();
} }
NoteTrack::NoteTrack(AudacityProject *project) NoteTrack::NoteTrack()
: NoteTrackBase(project) : NoteTrackBase()
{ {
SetDefaultName(_("Note Track")); SetDefaultName(_("Note Track"));
SetName(GetDefaultName()); SetName(GetDefaultName());
@ -172,7 +172,7 @@ Alg_seq &NoteTrack::GetSeq() const
Track::Holder NoteTrack::Clone() const Track::Holder NoteTrack::Clone() const
{ {
auto duplicate = std::make_shared<NoteTrack>(mProject); auto duplicate = std::make_shared<NoteTrack>();
duplicate->Init(*this); duplicate->Init(*this);
// The duplicate begins life in serialized state. Often the duplicate is // 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 // 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() ) ) //( std::min( t1, GetEndTime() ) ) - ( std::max( t0, GetStartTime() ) )
//); //);
auto newTrack = std::make_shared<NoteTrack>(mProject); auto newTrack = std::make_shared<NoteTrack>();
newTrack->Init(*this); newTrack->Init(*this);
@ -477,7 +477,7 @@ Track::Holder NoteTrack::Cut(double t0, double t1)
//AddToDuration( delta ); //AddToDuration( delta );
// What should be done with the rest of newTrack's members? // What should be done with the rest of newTrack's members?
//(mBottomNote, mProject, //(mBottomNote,
// mSerializationBuffer, mSerializationLength, mVisibleChannels) // mSerializationBuffer, mSerializationLength, mVisibleChannels)
return newTrack; return newTrack;
@ -490,7 +490,7 @@ Track::Holder NoteTrack::Copy(double t0, double t1, bool) const
double len = t1-t0; double len = t1-t0;
auto newTrack = std::make_shared<NoteTrack>(mProject); auto newTrack = std::make_shared<NoteTrack>();
newTrack->Init(*this); newTrack->Init(*this);
@ -500,7 +500,7 @@ Track::Holder NoteTrack::Copy(double t0, double t1, bool) const
newTrack->SetOffset(0); newTrack->SetOffset(0);
// What should be done with the rest of newTrack's members? // What should be done with the rest of newTrack's members?
// (mBottomNote, mProject, mSerializationBuffer, // (mBottomNote, mSerializationBuffer,
// mSerializationLength, mVisibleChannels) // mSerializationLength, mVisibleChannels)
return newTrack; return newTrack;

View File

@ -65,7 +65,7 @@ class AUDACITY_DLL_API NoteTrack final
: public NoteTrackBase : public NoteTrackBase
{ {
public: public:
NoteTrack(AudacityProject *project); NoteTrack();
virtual ~NoteTrack(); virtual ~NoteTrack();
using Holder = std::shared_ptr<NoteTrack>; using Holder = std::shared_ptr<NoteTrack>;

View File

@ -1245,7 +1245,7 @@ const TranslatableString & ProjectFileIO::GetLastError() const
const TranslatableString & ProjectFileIO::GetLibraryError() const const TranslatableString & ProjectFileIO::GetLibraryError() const
{ {
return mLastError; return mLibraryError;
} }
void ProjectFileIO::SetError(const TranslatableString & msg) void ProjectFileIO::SetError(const TranslatableString & msg)

View File

@ -80,7 +80,6 @@ private:
void UpdatePrefs() override; void UpdatePrefs() override;
using ExecCB = std::function<int(wxString *result, int cols, char **vals, char **names)>; using ExecCB = std::function<int(wxString *result, int cols, char **vals, char **names)>;
using ExecFunc = int (*)(void *data, int cols, char **vals, char **names);
struct ExecParm struct ExecParm
{ {
ExecCB func; ExecCB func;

View File

@ -144,8 +144,7 @@ SampleBlockPtr SampleBlock::Get(AudacityProject *project,
} }
SampleBlock::SampleBlock(AudacityProject *project) SampleBlock::SampleBlock(AudacityProject *project)
: mProject(project), : mIO(ProjectFileIO::Get(*project))
mIO(ProjectFileIO::Get(*project))
{ {
mValid = false; mValid = false;
mSilent = false; mSilent = false;

View File

@ -103,7 +103,6 @@ private:
void CalcSummary(); void CalcSummary();
private: private:
AudacityProject *mProject;
ProjectFileIO & mIO; ProjectFileIO & mIO;
bool mValid; bool mValid;
bool mDirty; bool mDirty;
@ -128,7 +127,6 @@ private:
const char *columns = const char *columns =
"sampleformat, summin, summax, sumrms, summary256, summary64k, samples"; "sampleformat, summin, summax, sumrms, summary256, summary64k, samples";
friend class ProjectFileIO;
#if defined(WORDS_BIGENDIAN) #if defined(WORDS_BIGENDIAN)
#error All sample block data is little endian...big endian not yet supported #error All sample block data is little endian...big endian not yet supported
#endif #endif

View File

@ -40,7 +40,6 @@
#include <wx/ffile.h> #include <wx/ffile.h>
#include <wx/log.h> #include <wx/log.h>
#include "ProjectFileIO.h"
#include "SampleBlock.h" #include "SampleBlock.h"
#include "InconsistencyException.h" #include "InconsistencyException.h"
#include "widgets/AudacityMessageBox.h" #include "widgets/AudacityMessageBox.h"

View File

@ -38,7 +38,7 @@
std::shared_ptr<TimeTrack> TrackFactory::NewTimeTrack() std::shared_ptr<TimeTrack> TrackFactory::NewTimeTrack()
{ {
return std::make_shared<TimeTrack>(&mProject, mZoomInfo); return std::make_shared<TimeTrack>(mZoomInfo);
} }
static ProjectFileIORegistry::Entry registerFactory{ static ProjectFileIORegistry::Entry registerFactory{
@ -53,8 +53,8 @@ static ProjectFileIORegistry::Entry registerFactory{
} }
}; };
TimeTrack::TimeTrack(AudacityProject *project, const ZoomInfo *zoomInfo): TimeTrack::TimeTrack(const ZoomInfo *zoomInfo):
Track(project) Track()
, mZoomInfo(zoomInfo) , mZoomInfo(zoomInfo)
{ {
mEnvelope = std::make_unique<BoundedEnvelope>(true, TIMETRACK_MIN, TIMETRACK_MAX, 1.0); mEnvelope = std::make_unique<BoundedEnvelope>(true, TIMETRACK_MIN, TIMETRACK_MAX, 1.0);

View File

@ -25,7 +25,7 @@ class TimeTrack final : public Track {
public: 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 /** @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 * Calls TimeTrack::Init() to copy the track metadata, then does a bunch of manipulations on the

View File

@ -46,9 +46,8 @@ and TimeTrack.
#pragma warning( disable : 4786 ) #pragma warning( disable : 4786 )
#endif #endif
Track::Track(AudacityProject *project) Track::Track()
: vrulerSize(36,0), : vrulerSize(36,0)
mProject(project)
{ {
mSelected = false; mSelected = false;
mLinked = false; mLinked = false;
@ -76,8 +75,6 @@ void Track::Init(const Track &orig)
mDefaultName = orig.mDefaultName; mDefaultName = orig.mDefaultName;
mName = orig.mName; mName = orig.mName;
mProject = orig.mProject;
mSelected = orig.mSelected; mSelected = orig.mSelected;
mLinked = orig.mLinked; mLinked = orig.mLinked;
mChannel = orig.mChannel; mChannel = orig.mChannel;

View File

@ -309,11 +309,9 @@ private:
ChannelType mChannel; ChannelType mChannel;
double mOffset; double mOffset;
mutable AudacityProject *mProject;
public: public:
Track(AudacityProject *project); Track();
Track(const Track &orig); Track(const Track &orig);
virtual ~ Track(); virtual ~ Track();
@ -352,12 +350,6 @@ public:
virtual void SetPan( float ){ ;} virtual void SetPan( float ){ ;}
virtual void SetPanFromChannelType(){ ;}; 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 // Create a NEW track and modify this track
// Return non-NULL or else throw // Return non-NULL or else throw
// May assume precondition: t0 <= t1 // May assume precondition: t0 <= t1
@ -716,8 +708,8 @@ protected:
class AUDACITY_DLL_API AudioTrack /* not final */ : public Track class AUDACITY_DLL_API AudioTrack /* not final */ : public Track
{ {
public: public:
AudioTrack(AudacityProject *project) AudioTrack()
: Track{ project } {} : Track{} {}
AudioTrack(const Track &orig) : Track{ orig } {} AudioTrack(const Track &orig) : Track{ orig } {}
// Serialize, not with tags of its own, but as attributes within a tag. // 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 class AUDACITY_DLL_API PlayableTrack /* not final */ : public AudioTrack
{ {
public: public:
PlayableTrack(AudacityProject *project) PlayableTrack()
: AudioTrack{ project } {} : AudioTrack{} {}
PlayableTrack(const Track &orig) : AudioTrack{ orig } {} PlayableTrack(const Track &orig) : AudioTrack{ orig } {}
bool GetMute () const { return mMute; } bool GetMute () const { return mMute; }

View File

@ -47,7 +47,6 @@ Track classes.
#include "Sequence.h" #include "Sequence.h"
#include "Spectrum.h" #include "Spectrum.h"
#include "Project.h"
#include "ProjectFileIORegistry.h" #include "ProjectFileIORegistry.h"
#include "ProjectSettings.h" #include "ProjectSettings.h"
@ -94,8 +93,10 @@ WaveTrack::Holder TrackFactory::NewWaveTrack(sampleFormat format, double rate)
return std::make_shared<WaveTrack> ( &mProject, format, rate ); return std::make_shared<WaveTrack> ( &mProject, format, rate );
} }
WaveTrack::WaveTrack(AudacityProject *project, sampleFormat format, double rate) : WaveTrack::WaveTrack( AudacityProject *project,
PlayableTrack(project) sampleFormat format, double rate )
: PlayableTrack()
, mProject(project)
{ {
mLegacyProjectFileOffset = 0; mLegacyProjectFileOffset = 0;
@ -142,6 +143,8 @@ WaveTrack::WaveTrack(const WaveTrack &orig):
void WaveTrack::Init(const WaveTrack &orig) void WaveTrack::Init(const WaveTrack &orig)
{ {
PlayableTrack::Init(orig); PlayableTrack::Init(orig);
mProject = orig.mProject;
mFormat = orig.mFormat; mFormat = orig.mFormat;
mWaveColorIndex = orig.mWaveColorIndex; mWaveColorIndex = orig.mWaveColorIndex;
mRate = orig.mRate; mRate = orig.mRate;

View File

@ -577,6 +577,10 @@ private:
// Private variables // Private variables
// //
// AS: Note that the mProject is mutable. This is
// mostly to support "Duplicate" of const objects
mutable AudacityProject *mProject;
wxCriticalSection mFlushCriticalSection; wxCriticalSection mFlushCriticalSection;
wxCriticalSection mAppendCriticalSection; wxCriticalSection mAppendCriticalSection;
double mLegacyProjectFileOffset; double mLegacyProjectFileOffset;