mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 07:40:23 +02:00
fix for crash on sort by name
This commit is contained in:
parent
45ad663e05
commit
811c4ffbc3
@ -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()) {
|
||||
|
@ -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 {
|
||||
|
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user