mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-22 07:10:06 +02:00
Track::GetLink and GetLinked are private, but SetLinked isn't yet
This commit is contained in:
parent
b36c3efec1
commit
2ee87082cb
@ -5478,20 +5478,10 @@ void MenuCommandHandler::OnRedo(const CommandContext &context)
|
||||
ModifyUndoMenuItems(project);
|
||||
}
|
||||
|
||||
void MenuCommandHandler::FinishCopy
|
||||
(const Track *n, Track *dest)
|
||||
{
|
||||
if (dest) {
|
||||
dest->SetChannel(n->GetChannel());
|
||||
dest->SetLinked(n->GetLinked());
|
||||
dest->SetName(n->GetName());
|
||||
}
|
||||
}
|
||||
|
||||
void MenuCommandHandler::FinishCopy
|
||||
(const Track *n, Track::Holder &&dest, TrackList &list)
|
||||
{
|
||||
FinishCopy( n, dest.get() );
|
||||
Track::FinishCopy( n, dest.get() );
|
||||
if (dest)
|
||||
list.Add(std::move(dest));
|
||||
}
|
||||
@ -6037,7 +6027,7 @@ bool MenuCommandHandler::HandlePasteNothingSelected(AudacityProject &project)
|
||||
if (uNewTrack)
|
||||
FinishCopy(pClip, std::move(uNewTrack), *tracks);
|
||||
else
|
||||
FinishCopy(pClip, pNewTrack);
|
||||
Track::FinishCopy(pClip, pNewTrack);
|
||||
}
|
||||
|
||||
// Select some pasted samples, which is probably impossible to get right
|
||||
|
@ -270,10 +270,7 @@ void OnExit(const CommandContext &context );
|
||||
void OnUndo(const CommandContext &context );
|
||||
void OnRedo(const CommandContext &context );
|
||||
|
||||
static void FinishCopy(const Track *n, Track *dest);
|
||||
static void FinishCopy
|
||||
(const Track *n, Track::Holder &&dest, TrackList &list);
|
||||
|
||||
static void FinishCopy(const Track *n, Track::Holder &&dest, TrackList &list);
|
||||
|
||||
void OnCut(const CommandContext &context );
|
||||
void OnSplitCut(const CommandContext &context );
|
||||
|
@ -3138,46 +3138,7 @@ void AudacityProject::OpenFile(const wxString &fileNameArg, bool addtohistory)
|
||||
err = true;
|
||||
}
|
||||
|
||||
// Sanity checks for linked tracks; unsetting the linked property
|
||||
// doesn't fix the problem, but it likely leaves us with orphaned
|
||||
// blockfiles instead of much worse problems.
|
||||
if (t->GetLinked())
|
||||
{
|
||||
Track *l = t->GetLink();
|
||||
if (l)
|
||||
{
|
||||
// A linked track's partner should never itself be linked
|
||||
if (l->GetLinked())
|
||||
{
|
||||
wxLogWarning(
|
||||
wxT("Left track %s had linked right track %s with extra right track link.\n Removing extra link from right track."),
|
||||
t->GetName(), l->GetName());
|
||||
err = true;
|
||||
l->SetLinked(false);
|
||||
}
|
||||
|
||||
// Channels should be left and right
|
||||
if ( !( (t->GetChannel() == Track::LeftChannel &&
|
||||
l->GetChannel() == Track::RightChannel) ||
|
||||
(t->GetChannel() == Track::RightChannel &&
|
||||
l->GetChannel() == Track::LeftChannel) ) )
|
||||
{
|
||||
wxLogWarning(
|
||||
wxT("Track %s and %s had left/right track links out of order. Setting tracks to not be linked."),
|
||||
t->GetName(), l->GetName());
|
||||
err = true;
|
||||
t->SetLinked(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogWarning(
|
||||
wxT("Track %s had link to NULL track. Setting it to not be linked."),
|
||||
t->GetName());
|
||||
err = true;
|
||||
t->SetLinked(false);
|
||||
}
|
||||
}
|
||||
err = ( !t->LinkConsistencyCheck() ) || err;
|
||||
|
||||
mLastSavedTracks->Add(t->Duplicate());
|
||||
}
|
||||
@ -5222,7 +5183,7 @@ void AudacityProject::EditClipboardByLabel( EditDestFunction action )
|
||||
auto dest = ( wt->*action )( region.start, region.end );
|
||||
if( dest )
|
||||
{
|
||||
MenuCommandHandler::FinishCopy( wt, dest.get() );
|
||||
Track::FinishCopy( wt, dest.get() );
|
||||
if( !merged )
|
||||
merged = std::move(dest);
|
||||
else
|
||||
|
@ -408,6 +408,63 @@ bool Track::IsLeader() const
|
||||
bool Track::IsSelectedLeader() const
|
||||
{ return IsSelected() && IsLeader(); }
|
||||
|
||||
void Track::FinishCopy
|
||||
(const Track *n, Track *dest)
|
||||
{
|
||||
if (dest) {
|
||||
dest->SetChannel(n->GetChannel());
|
||||
dest->SetLinked(n->GetLinked());
|
||||
dest->SetName(n->GetName());
|
||||
}
|
||||
}
|
||||
|
||||
bool Track::LinkConsistencyCheck()
|
||||
{
|
||||
// Sanity checks for linked tracks; unsetting the linked property
|
||||
// doesn't fix the problem, but it likely leaves us with orphaned
|
||||
// blockfiles instead of much worse problems.
|
||||
bool err = false;
|
||||
if (GetLinked())
|
||||
{
|
||||
Track *l = GetLink();
|
||||
if (l)
|
||||
{
|
||||
// A linked track's partner should never itself be linked
|
||||
if (l->GetLinked())
|
||||
{
|
||||
wxLogWarning(
|
||||
wxT("Left track %s had linked right track %s with extra right track link.\n Removing extra link from right track."),
|
||||
GetName().c_str(), l->GetName());
|
||||
err = true;
|
||||
l->SetLinked(false);
|
||||
}
|
||||
|
||||
// Channels should be left and right
|
||||
if ( !( (GetChannel() == Track::LeftChannel &&
|
||||
l->GetChannel() == Track::RightChannel) ||
|
||||
(GetChannel() == Track::RightChannel &&
|
||||
l->GetChannel() == Track::LeftChannel) ) )
|
||||
{
|
||||
wxLogWarning(
|
||||
wxT("Track %s and %s had left/right track links out of order. Setting tracks to not be linked."),
|
||||
GetName(), l->GetName());
|
||||
err = true;
|
||||
SetLinked(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wxLogWarning(
|
||||
wxT("Track %s had link to NULL track. Setting it to not be linked."),
|
||||
GetName());
|
||||
err = true;
|
||||
SetLinked(false);
|
||||
}
|
||||
}
|
||||
|
||||
return ! err;
|
||||
}
|
||||
|
||||
std::pair<Track *, Track *> TrackList::FindSyncLockGroup(Track *pMember) const
|
||||
{
|
||||
if (!pMember)
|
||||
|
21
src/Track.h
21
src/Track.h
@ -315,13 +315,24 @@ public:
|
||||
void SetMinimized(bool isMinimized);
|
||||
protected:
|
||||
virtual void DoSetMinimized(bool isMinimized);
|
||||
public:
|
||||
|
||||
Track *GetLink() const;
|
||||
public:
|
||||
static void FinishCopy (const Track *n, Track *dest);
|
||||
|
||||
// For use when loading a file. Return true if ok, else make repair
|
||||
bool LinkConsistencyCheck();
|
||||
|
||||
private:
|
||||
std::shared_ptr<TrackList> GetOwner() const { return mList.lock(); }
|
||||
|
||||
Track *GetLink() const;
|
||||
bool GetLinked () const { return mLinked; }
|
||||
public:
|
||||
void SetLinked (bool l);
|
||||
private:
|
||||
// No need yet to make this virtual
|
||||
void DoSetLinked(bool l);
|
||||
|
||||
TrackNodePointer GetNode() const;
|
||||
void SetOwner
|
||||
(const std::weak_ptr<TrackList> &list, TrackNodePointer node);
|
||||
@ -358,13 +369,9 @@ private:
|
||||
void SetDefaultName( const wxString &n ) { mDefaultName = n; }
|
||||
|
||||
bool GetSelected() const { return mSelected; }
|
||||
|
||||
virtual void SetSelected(bool s);
|
||||
|
||||
bool GetLinked () const { return mLinked; }
|
||||
void SetLinked (bool l);
|
||||
private:
|
||||
// No need yet to make this virtual
|
||||
void DoSetLinked(bool l);
|
||||
public:
|
||||
|
||||
virtual ChannelType GetChannel() const { return mChannel;}
|
||||
|
Loading…
x
Reference in New Issue
Block a user