1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-19 09:01:15 +02:00

Simplify by removing many std::move of shared_ptr to tracks...

... Don't need them, as we did with std::unique_ptr
This commit is contained in:
Paul Licameli
2018-11-19 13:17:28 -05:00
parent a0aa69a248
commit 41175e94cd
12 changed files with 47 additions and 49 deletions

View File

@@ -20,11 +20,11 @@
// private helper classes and functions
namespace {
void FinishCopy
(const Track *n, Track::Holder &&dest, TrackList &list)
(const Track *n, const Track::Holder &dest, TrackList &list)
{
Track::FinishCopy( n, dest.get() );
if (dest)
list.Add(std::move(dest));
list.Add( dest );
}
// Handle text paste (into active label), if any. Return true if did paste.
@@ -124,7 +124,7 @@ bool DoPasteNothingSelected(AudacityProject &project)
pNewTrack->SetSelected(true);
if (uNewTrack)
FinishCopy(pClip, std::move(uNewTrack), *tracks);
FinishCopy(pClip, uNewTrack, *tracks);
else
Track::FinishCopy(pClip, pNewTrack);
}
@@ -303,13 +303,13 @@ void OnCut(const CommandContext &context)
// Since portsmf has a built-in cut operator, we use that instead
auto dest = n->Cut(selectedRegion.t0(),
selectedRegion.t1());
FinishCopy(n, std::move(dest), newClipboard);
FinishCopy(n, dest, newClipboard);
},
#endif
[&](Track *n) {
auto dest = n->Copy(selectedRegion.t0(),
selectedRegion.t1());
FinishCopy(n, std::move(dest), newClipboard);
FinishCopy(n, dest, newClipboard);
}
);
@@ -405,7 +405,7 @@ void OnCopy(const CommandContext &context)
for (auto n : tracks->Selected()) {
auto dest = n->Copy(selectedRegion.t0(),
selectedRegion.t1());
FinishCopy(n, std::move(dest), newClipboard);
FinishCopy(n, dest, newClipboard);
}
// Survived possibility of exceptions. Commit changes to the clipboard now.
@@ -702,7 +702,7 @@ void OnDuplicate(const CommandContext &context)
selectedRegion.t1(), false);
dest->Init(*n);
dest->SetOffset(wxMax(selectedRegion.t0(), n->GetOffset()));
tracks->Add(std::move(dest));
tracks->Add( dest );
// This break is really needed, else we loop infinitely
if (n == last)
@@ -733,7 +733,7 @@ void OnSplitCut(const CommandContext &context)
selectedRegion.t0(),
selectedRegion.t1());
if (dest)
FinishCopy(n, std::move(dest), newClipboard);
FinishCopy(n, dest, newClipboard);
},
[&](Track *n) {
dest = n->Copy(selectedRegion.t0(),
@@ -741,7 +741,7 @@ void OnSplitCut(const CommandContext &context)
n->Silence(selectedRegion.t0(),
selectedRegion.t1());
if (dest)
FinishCopy(n, std::move(dest), newClipboard);
FinishCopy(n, dest, newClipboard);
}
);
@@ -926,7 +926,7 @@ void OnSplitNew(const CommandContext &context)
dest = wt->SplitCut(newt0, newt1);
if (dest) {
dest->SetOffset(wxMax(newt0, offset));
FinishCopy(wt, std::move(dest), *tracks);
FinishCopy(wt, dest, *tracks);
}
}
#if 0
@@ -938,7 +938,7 @@ void OnSplitNew(const CommandContext &context)
viewInfo.selectedRegion.t1());
if (dest) {
dest->SetOffset(wxMax(0, n->GetOffset()));
FinishCopy(n, std::move(dest), *tracks);
FinishCopy(n, dest, *tracks);
}
}
#endif

View File

@@ -117,7 +117,7 @@ AudacityProject *DoImportMIDI(
if (::ImportMIDI(fileName, newTrack.get())) {
pProject->SelectNone();
auto pTrack = tracks->Add(std::move(newTrack));
auto pTrack = tracks->Add( newTrack );
pTrack->SetSelected(true);
pProject->PushState(wxString::Format(_("Imported MIDI from '%s'"),
@@ -464,7 +464,7 @@ void OnImportLabels(const CommandContext &context)
project.SelectNone();
newTrack->SetSelected(true);
tracks->Add(std::move(newTrack));
tracks->Add( newTrack );
project.PushState(wxString::
Format(_("Imported labels from '%s'"), fileName),

View File

@@ -201,7 +201,7 @@ void EditClipboardByLabel(
{
Track::FinishCopy( wt, dest.get() );
if( !merged )
merged = std::move(dest);
merged = dest;
else
{
// Paste to the beginning; unless this is the first region,
@@ -227,7 +227,7 @@ void EditClipboardByLabel(
regions.at(i + 1).start - region.end);
}
if( merged )
newClipboard.Add( std::move(merged) );
newClipboard.Add( merged );
}
// Survived possibility of exceptions. Commit changes to the clipboard now.

View File

@@ -59,10 +59,10 @@ void DoMixAndRender
// Add NEW tracks
auto pNewLeft = tracks->Add(std::move(uNewLeft));
auto pNewLeft = tracks->Add( uNewLeft );
decltype(pNewLeft) pNewRight{};
if (uNewRight)
pNewRight = tracks->Add(std::move(uNewRight));
pNewRight = tracks->Add( uNewRight );
// Do this only after adding tracks to the list
tracks->GroupChannels(*pNewLeft, pNewRight ? 2 : 1);
@@ -1188,7 +1188,7 @@ void OnScoreAlign(const CommandContext &context)
}
if (result == SA_SUCCESS) {
tracks->Replace(nt, std::move(holder));
tracks->Replace(nt, holder);
project.RedrawProject();
AudacityMessageBox(wxString::Format(
_("Alignment completed: MIDI from %.2f to %.2f secs, Audio from %.2f to %.2f secs."),