1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-01-09 22:27:07 +01:00

Remove MixerTrackClusters right to left, remove assertion

This commit is contained in:
Paul Licameli
2017-03-29 00:41:36 -04:00
parent b2ab9b5087
commit ed0088491c
2 changed files with 12 additions and 12 deletions

View File

@@ -920,7 +920,7 @@ void MixerBoard::UpdateTrackClusters()
this->CreateMuteSoloImages(); this->CreateMuteSoloImages();
const int nClusterHeight = mScrolledWindow->GetClientSize().GetHeight() - kDoubleInset; const int nClusterHeight = mScrolledWindow->GetClientSize().GetHeight() - kDoubleInset;
const size_t nClusterCount = mMixerTrackClusters.GetCount(); size_t nClusterCount = mMixerTrackClusters.GetCount();
unsigned int nClusterIndex = 0; unsigned int nClusterIndex = 0;
TrackListIterator iterTracks(mTracks); TrackListIterator iterTracks(mTracks);
MixerTrackCluster* pMixerTrackCluster = NULL; MixerTrackCluster* pMixerTrackCluster = NULL;
@@ -971,15 +971,14 @@ void MixerBoard::UpdateTrackClusters()
this->UpdateWidth(); this->UpdateWidth();
this->ResizeTrackClusters(); this->ResizeTrackClusters();
} }
else if (nClusterIndex < nClusterCount) else while (nClusterIndex < nClusterCount)
{ {
// We've got too many clusters. // We've got too many clusters.
// This can happen only on things like Undo New Audio Track or Undo Import // This can happen only on things like Undo New Audio Track or Undo Import
// that don't call RemoveTrackCluster explicitly. // that don't call RemoveTrackCluster explicitly.
// We've already updated the track pointers for the clusters to the left, so just remove all the rest. // We've already updated the track pointers for the clusters to the left, so just remove all the rest.
// Keep nClusterIndex constant and successively DELETE from left to right. // Successively DELETE from right to left.
for (unsigned int nCounter = nClusterIndex; nCounter < nClusterCount; nCounter++) RemoveTrackCluster(--nClusterCount);
this->RemoveTrackCluster(mMixerTrackClusters[nClusterIndex]->mTrack);
} }
} }
@@ -1032,9 +1031,16 @@ void MixerBoard::RemoveTrackCluster(const PlayableTrack* pTrack)
// Find and destroy. // Find and destroy.
MixerTrackCluster* pMixerTrackCluster; MixerTrackCluster* pMixerTrackCluster;
int nIndex = this->FindMixerTrackCluster(pTrack, &pMixerTrackCluster); int nIndex = this->FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
if (pMixerTrackCluster == NULL) if (pMixerTrackCluster == NULL)
return; // Couldn't find it. return; // Couldn't find it.
RemoveTrackCluster(nIndex);
}
void MixerBoard::RemoveTrackCluster(size_t nIndex)
{
auto pMixerTrackCluster = mMixerTrackClusters[nIndex];
mMixerTrackClusters.RemoveAt(nIndex); mMixerTrackClusters.RemoveAt(nIndex);
pMixerTrackCluster->Destroy(); // DELETE is unsafe on wxWindow. pMixerTrackCluster->Destroy(); // DELETE is unsafe on wxWindow.
@@ -1053,13 +1059,6 @@ void MixerBoard::RemoveTrackCluster(const PlayableTrack* pTrack)
} }
this->UpdateWidth(); this->UpdateWidth();
#ifdef EXPERIMENTAL_MIDI_OUT
// Sanity check: if there is still a MixerTrackCluster with pTrack, then
// we deleted the first but should have deleted the last:
FindMixerTrackCluster(pTrack, &pMixerTrackCluster);
wxASSERT(pMixerTrackCluster == NULL);
#endif
} }

View File

@@ -204,6 +204,7 @@ public:
int GetTrackClustersWidth(); int GetTrackClustersWidth();
void MoveTrackCluster(const PlayableTrack* pTrack, bool bUp); // Up in TrackPanel is left in MixerBoard. void MoveTrackCluster(const PlayableTrack* pTrack, bool bUp); // Up in TrackPanel is left in MixerBoard.
void RemoveTrackCluster(const PlayableTrack* pTrack); void RemoveTrackCluster(const PlayableTrack* pTrack);
void RemoveTrackCluster(size_t nIndex);
wxBitmap* GetMusicalInstrumentBitmap(const Track *pTrack); wxBitmap* GetMusicalInstrumentBitmap(const Track *pTrack);