fix for crash on sort by name

This commit is contained in:
mchinen 2010-05-04 03:14:43 +00:00
parent 45ad663e05
commit 811c4ffbc3
3 changed files with 14 additions and 4 deletions

View File

@ -2012,6 +2012,8 @@ void AudacityProject::OnSortName()
wxArrayPtrVoid arr;
TrackListIterator iter(mTracks);
Track *track = iter.First();
//Assumes that linked channels have the same name.
//if this is not true a crash will occur during redraw after the sort.
while (track) {
for (ndx = 0; ndx < (int)arr.GetCount(); ndx++) {
if (track->GetName() < ((Track *) arr[ndx])->GetName()) {

View File

@ -3269,14 +3269,17 @@ void AudacityProject::AddImportedTracks(wxString fileName,
bool initiallyEmpty = mTracks->IsEmpty();
double newRate = 0;
wxString trackNameBase = fileName.AfterLast(wxFILE_SEP_PATH).BeforeLast('.');
bool isLinked = false;
for (int i = 0; i < numTracks; i++) {
if (newRate == 0 && newTracks[i]->GetKind() == Track::Wave) {
newRate = ((WaveTrack *)newTracks[i])->GetRate();
}
mTracks->Add(newTracks[i]);
newTracks[i]->SetSelected(true);
if (numTracks > 2 || (numTracks > 1 && !newTracks[i]->GetLink())) {
//we need to check link status based on the first channel only.
if(0==i)
isLinked = newTracks[i]->GetLinked();
if (numTracks > 2 || (numTracks > 1 && !isLinked) ) {
newTracks[i]->SetName(trackNameBase + wxString::Format(wxT(" %d" ), i + 1));
}
else {

View File

@ -6793,9 +6793,14 @@ void TrackPanel::OnSetName(wxCommandEvent &event)
wxString defaultStr = t->GetName();
wxString newName = wxGetTextFromUser(_("Change track name to:"),
_("Track Name"), defaultStr);
if (newName != wxT(""))
//if we have a linked channel this name should change as well (otherwise sort by name and time will crash)
if (newName != wxT("")) {
t->SetName(newName);
if(t->GetLinked())
{
t->GetLink()->SetName(newName);
}
}
#ifdef EXPERIMENTAL_MIXER_BOARD
MixerBoard* pMixerBoard = this->GetMixerBoard();
if (pMixerBoard && (t->GetKind() == Track::Wave))