Applying pending changed tracks causes adoption of cell objects...

... This will simplify the updating of pending tracks when state is moved into
the view cell object.  No copies of those fields will then be needed.
This commit is contained in:
Paul Licameli 2019-06-18 00:18:23 -04:00
parent d335276931
commit 7a91cc8e8d
2 changed files with 12 additions and 3 deletions

View File

@ -1124,8 +1124,13 @@ std::shared_ptr<Track>
TrackList::RegisterPendingChangedTrack( Updater updater, Track *src )
{
std::shared_ptr<Track> pTrack;
if (src)
pTrack = src->Duplicate();
if (src) {
pTrack = src->Clone(); // not duplicate
// Share the satellites with the original, though they do not point back
// to the pending track
pTrack->mpView = src->mpView;
pTrack->mpControls = src->mpControls;
}
if (pTrack) {
mUpdaters.push_back( updater );
@ -1211,6 +1216,10 @@ bool TrackList::ApplyPendingTracks()
for (auto &pendingTrack : updates) {
if (pendingTrack) {
if (pendingTrack->mpView)
pendingTrack->mpView->Reparent( pendingTrack );
if (pendingTrack->mpControls)
pendingTrack->mpControls->Reparent( pendingTrack );
auto src = FindById( pendingTrack->GetId() );
if (src)
this->Replace(src, pendingTrack), result = true;

View File

@ -741,7 +741,7 @@ protected:
// These hold the controls:
std::shared_ptr<TrackView> mpView;
std::shared_ptr<TrackControls> mpControls;
std::shared_ptr<CommonTrackCell> mpControls;
};
class AUDACITY_DLL_API AudioTrack /* not final */ : public Track